home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Updates / Librarys / MMULib / Autodocs / mmu.doc < prev   
Text File  |  1999-11-20  |  117KB  |  3,464 lines

  1. TABLE OF CONTENTS
  2.  
  3. mmu.library/--Background--
  4. mmu.library/--Patches--
  5. mmu.library/CreateMMUContext
  6. mmu.library/DeleteMMUContext
  7. mmu.library/EnterMMUContext
  8. mmu.library/LeaveMMUContext
  9. mmu.library/CurrentContext
  10. mmu.library/AddContextHook
  11. mmu.library/RemContextHook
  12. mmu.library/AddMessageHook
  13. mmu.library/RemMessageHook
  14. mmu.library/ActivateException
  15. mmu.library/DeactivateException
  16. mmu.library/GetPageSize    
  17. mmu.library/RemapSize
  18. mmu.library/SetPropertiesA
  19. mmu.library/SetPagePropertiesA
  20. mmu.library/RebuildTree
  21. mmu.library/RebuildTreesA
  22. mmu.library/GetPropertiesA
  23. mmu.library/GetPagePropertiesA
  24. mmu.library/AllocAligned
  25. mmu.library/LockMMUContext
  26. mmu.library/UnlockMMUContext
  27. mmu.library/AttemptLockMMUContext
  28. mmu.library/LockContextList
  29. mmu.library/UnlockContextList
  30. mmu.library/AttemptLockContextList
  31. mmu.library/AllocLineVec
  32. mmu.library/PhysicalPageLocation
  33. mmu.library/PhysicalLocation
  34. mmu.library/DMAInitiate
  35. mmu.library/DMATerminate
  36. mmu.library/GetMapping
  37. mmu.library/ReleaseMapping
  38. mmu.library/NewMapping
  39. mmu.library/CopyMapping
  40. mmu.library/DupMapping
  41. mmu.library/CopyContextRegion
  42. mmu.library/SetPropertiesMapping
  43. mmu.library/SetMappingPropertiesA
  44. mmu.library/GetMappingPropertiesA
  45. mmu.library/SetPropertyList
  46. mmu.library/GetMMUType
  47. mmu.library/SuperContext
  48. mmu.library/DefaultContext
  49. mmu.library/WithoutMMU
  50. mmu.library/SetBusError
  51. mmu.library/GetMMUContextData
  52. mmu.library/SetMMUContextDataA
  53. mmu.library/BuildIndirect
  54. mmu.library/SetIndirect
  55. mmu.library/GetIndirect
  56.  
  57. mmu.library/--Background--                            mmu.library/--Background--
  58.  
  59.     PURPOSE
  60.         The mmu.library provides functions for MMU related operations
  61.         as write- or read-protecting certain areas of memory for a
  62.         given set of tasks, or marking memory regions as "swapped"
  63.         virtual memory support. It offers an abstraction level on top
  64.         of the actual MMU and a unified interface for MMU purposes.
  65.  
  66.         The MMU lib does NOT implement virtual memory, that's the purpose
  67.         of another library - the memory.library. There's no much reason why
  68.         any application except the memory.library and probably some debugging
  69.         tools should call this library directly. The memory.library functions
  70.         on top of this library should suffer for "all day purposes".
  71.  
  72.         The basic object administrated by this library is the "context". A
  73.         "context" is the software abstraction of a MMU translation tree, it
  74.         keeps the information of the status of memory. The mmu.library 
  75.         provides a "global" context that represents the MMU translation tree
  76.         for all tasks. It is build by the init code of the library either by
  77.         snooping the already existing MMU translation tree or by building an
  78.         own tree by looking at the available memory and expansion devices.
  79.  
  80.         Programs can build own contexts by using the MMU library functions and
  81.         may enter or leave the contexts generated in this way. Several tasks
  82.         may share one context, as they represent, for example, multiple 
  83.         "threads" of one single program. Thus, the notation used here is some-
  84.         how turned around: A "context" in the amiga world is called "process"
  85.         in unix, and a "task" or "process" in the amiga world is called a
  86.         "thread" usually.
  87.  
  88.         Tasks that do not enter an own context explicitly share the common
  89.         global context. Even though it is possible to change the global 
  90.         context, this technique should be used only by debugging tools as the
  91.         enforcer. It could, for example, mark unused areas of the memory as
  92.         well as the first 4K as "invalid".
  93.  
  94.         The MMU library provides two "hooks" for each context, the 
  95.         "bus error hook" and the "segmentation fault" hook. The first hook
  96.         is called if an access to an invalid memory location is detected, or
  97.         a write to a read-only memory area. The second is called if an access
  98.         to a memory page marked as "swapped out" is detected. It's part of
  99.         the service of the MMU library to keep these two access violations
  100.         apart.
  101.  
  102.         The default hooks call simply the exception handler of the running
  103.         task, which generates by default the well known "guru". It's up to
  104.         programs on top of the MMU library to setup useful hooks. An enforcer
  105.         like tool might set "bus error hook" to print some useful information
  106.         about the access violation, the memory.library will set the 
  107.         "segmentation fault" hook to swap in the memory in question.
  108.  
  109.         The hooks are really "low-level" routines and are executed in super-
  110.         visor mode, and therefore very limited in power.
  111.  
  112.         The library provides itself a ready-for-use hook function which
  113.         sends a message to a task to be specified and suspends the task
  114.         that caused the bus error until the message is replied.
  115.  
  116.         MMU trees are managed on two levels, a "software abstraction level"
  117.         which is comfortable and easy to use. Memory "properties" of large
  118.         regions of memory can be redefined quite easely with one single
  119.         call, but rebuilding the MMU table tree from this abstraction layer
  120.         is a lengthly operation and requires quite a lot of CPU power
  121.         not available in critical applications.
  122.         Therefore, a more "hardware based" approach is available which
  123.         modifies the existing MMU table "on the fly" and is therefore
  124.         rather fast. However, memory pages to be handled like this must
  125.         be marked with the MAPP_SINGLE property to tell the library to
  126.         build the MMU table in a special way to allow fast modification
  127.         and to bypass some possible optimizations (e.g. "early page
  128.         terminators" and "invalid descriptors not at page level").
  129.         Modifications on this level are never seen by the abstraction
  130.         level above and should be used only once the MMU tree is complete.
  131.  
  132.         If that is, too, not fast enough, the MMU library allows building
  133.         pages using "indirect descriptors". That is, the page property
  134.         flags are given by a true hardware descriptor you provide. This
  135.         makes code CPU specific, obviously, but has the advantage that
  136.         page properties can be modified by a single long word "poke" in
  137.         your program, and the proper ATC flush. This is almost "hardware
  138.         banging", with some support.
  139.  
  140.         This method has one important drawback, namely that the library
  141.         is no longer able to disable caching for DMA transfer to and from
  142.         this page. Hence, NEVER EVER access an indirect page by DMA.
  143.  
  144. mmu.library/--Patches--                                mmu.library/--Patches--
  145.  
  146.         To perform its job, the mmu.library has to install a number of 
  147.         system patches. I tried avoid this as best as possible, but some
  148.         installations have to be done.
  149.  
  150.         The following patches are installed:
  151.  
  152.  
  153. exec/CacheControl:        Replaced partially by a function that guarantees
  154.                         that the data cache remains off when the mmu.library
  155.                         builds descriptors.
  156.  
  157. exec/ColdReboot:        Replaced partially by a function that removes the
  158.                         mmu.library installed MMU trees. This is done to
  159.                         restart the processor with a clean MMU setup.
  160.  
  161. exec/Alert:                Replaced partially. The Alert() replacement routine
  162.                         will check whether the alert caused is fatal or not,
  163.                         and will Disable() and unload the mmu.library 
  164.                         installed MMU tree if this is the case. Since a
  165.                         deadend alert will go over into a reset without
  166.                         calling ColdReboot(), this must be done here 
  167.                         separately to ensure that the machine restarts
  168.                         properly.
  169.  
  170. exec/AddMem:            Adding memory with a MMU setup active would or would
  171.                         not mean that the MMU table must be adjusted to
  172.                         reflect the changes. This function should not be
  173.                         called once the system is setup and running.
  174.                         It is here patched to an Alert(). 
  175.                         The original routine is not called because some
  176.                         68040/68060 libraries modify the MMU table on their 
  177.                         own in case this happens.
  178.                         I don't think this routine is really required unless
  179.                         on startup, but in case it is I will replace it
  180.                         completely on demand.
  181.  
  182. exec/AddConfigDev:        Patched to an Alert() for just the same reason than
  183.                         above.
  184.  
  185. exec/CachePreDMA:        Replaced completely by a MMU library routine that
  186.                         disables copyback mode for non-aligned pages and
  187.                         translates the logical address passed in to the
  188.                         physical address, by means of the mmu.library 
  189.                         public context.
  190.  
  191. exec/CachePostDMA:        Ditto. Replaced completely by the MMU.library.
  192.  
  193.         
  194.  
  195. mmu.library/CreateMMUContext                        mmu.library/CreateContext                        mmu.library/CreateMMUContext
  196.  
  197.     NAME
  198.         CreateMMUContext - Build a new MMU context.
  199.  
  200.     SYNOPSIS
  201.         context = CreateMMUContextA ( tags );
  202.         d0                              a0
  203.  
  204.         context = CreateMMUContext ( tag1, ... ); 
  205.  
  206.  
  207.         struct MMUContext * CreateMMUContextA ( struct TagItem *);
  208.  
  209.         struct MMUContext * CreateMMUContext ( Tag tag1, ... );
  210.         
  211.     FUNCTION
  212.         This function builds a new MMU context.
  213.  
  214.         The context created will be a copy of the global context, with
  215.         all memory regions marked in the same way and the same hooks
  216.         installed.
  217.  
  218.     INPUTS
  219.         tags    -    Tag items for the context to be created. 
  220.  
  221.         Currently defined tags are:
  222.  
  223.  
  224.         MCXTAG_COPY        -    build a copy of the context * passed in,
  225.                             if the pointer is NULL, build a copy of
  226.                             the global default context.
  227.  
  228.                             If this tag item is not given, all context
  229.                             addresses will be marked as MAPP_BLANK. Most
  230.                             likely not what you want.
  231.  
  232.                             If you specify a different table size than that
  233.                             of the context you want to clone you should
  234.                             specify the MCXTAG_ERRORCODE as well and study
  235.                             the return code carefully. The mmu library might
  236.                             have performed some rounding to fit the old
  237.                             table specifications into the new table layout.
  238.                             In worst case, this will make your new table
  239.                             unusable. It is therefore in general not a good
  240.                             idea to specify a page size larger than that of
  241.                             the cloned context. Even though the library 
  242.                             itself allocates all its internal structures
  243.                             aligned to "worst case" page sizes, this might
  244.                             not be true for external user programs.
  245.                             
  246.         MCXTAG_EXECBASE    -    allow accesses of AbsExecBase and all accesses
  247.                             except for the first KByte, even if the first
  248.                             page in the MMU tree - the "zeropage" - is
  249.                             marked as invalid. This is an important feature
  250.                             if the mmu.library is used to implement an
  251.                             Enforcer type program. 
  252.                             Accesses will be emulated in software and are
  253.                             hence *slow*. They should be avoided.
  254.                             AbsExecBase accesses are handled with highest
  255.                             priority first and might be faster, even though
  256.                             they're still slower than "the real thing".
  257.                             It is not guaranteed that the library will really
  258.                             read AbsExecBase from location four, dependent on
  259.                             some internals, it might give you a cached copy
  260.                             instead. This means usually no problem since
  261.                             AbsExecBase must not change while the machine is
  262.                             up and running. 
  263.  
  264.                             This option defaults to TRUE.
  265.  
  266.                             For more quirks about the zeropage, read the
  267.                             MCXTAG_ZEROBASE tag documentation below.
  268.  
  269.         MCXTAG_BLANKFILL -    defines a ULONG word fill value for blank
  270.                             memory regions.
  271.                     
  272.                             This ULONG is read by the CPU in case a program
  273.                             tries an access to "empty" memory regions. It
  274.                             defaults to 0L, but other values might be use-
  275.                             ful for debugging.
  276.  
  277.         MCXTAG_MEMORYATTRS-    An exec memory attributes specifier to be used
  278.                             for allocating memory for the (hardware) MMU
  279.                             tables. Defaults to MEMF_PUBLIC, check 
  280.                             exec/memory.h for other possibilities.
  281.  
  282.         MCXTAG_PRIVATESUPER    A boolean value, either TRUE or FALSE. If TRUE,
  283.                             build a private MMU supervisor table for this
  284.                             context, independent of the global supervisor
  285.                             table. BE WARNED! This means specifically that
  286.                             possible modifications of the global supervisor
  287.                             context will not be carried on your private
  288.                             supervisor table.
  289.                             Even if you pass in FALSE here, the library might
  290.                             still ignore your choice and build a private
  291.                             supervisor table anyways. This happens if the
  292.                             table layout you've chosen is different to the
  293.                             default table layout, making the user tree in-
  294.                             compatible to the default supervisor tree.
  295.                             
  296.         MCXTAG_ZEROBASE        This option takes only effect if MCXTAG_EXECBASE
  297.                             is TRUE and the first page of the MMU table build
  298.                             by you is invalid. This means that the MMU
  299.                             library will emulate accesses to all addresses
  300.                             in the first page up to the first KByte which
  301.                             remains unavailable to implement an "Enforcer"
  302.                             function. This tag provides a base address to
  303.                             which page these accesses have to be redirected.
  304.                             This tag defaults to NULL meaning that the 
  305.                             library will redirect accesses to the true 
  306.                             zeropage, making it available temporarely, but
  307.                             any other memory location - provided it is page 
  308.                             aligned - can be specified here as well. This
  309.                             is important if the zero page gets remapped to
  310.                             a different location, and an Enforcer type 
  311.                             program is run later on. The zero page remapper
  312.                             should specify this tag to redirect accesses 
  313.                             transparently, even if an Enforcer type 
  314.                             application invalidates the zero page. Failing
  315.                             to do so would make the MMU library emulating
  316.                             the access to the incorrect, non-remapped memory 
  317.                             location. Since other programs might want to
  318.                             build a private MMU table with a different
  319.                             table size, it is *NOT* enough to align the
  320.                             remap destination of the zeropage to GetPageSize()
  321.                             boundaries, RemapSize() alignment is required!
  322.                             THIS IS AN ADVANCED FEATURE.
  323.  
  324.         The next tag items define the MMU table layout. A logical address,
  325.         used as input for the MMU, consists of exactly 32 bits. These
  326.         bits are now split from the left to the right into groups to define
  327.         a "path" in the MMU tree. Each "level" of the MMU tree should be
  328.         considered as an array of pointers, pointing to the next lower
  329.         level of the tree. The nodes of the tree are contain the descriptors
  330.         that define how the address belonging to the path from the root to
  331.         this descriptor should be handled. For example, consider a three-
  332.         level tree with 7 bits for level A and B, 6 bits for level C and
  333.         12 bits for the page. The address 0x01feabcd would be used like this
  334.         to find an descriptor:
  335.  
  336.         hex 0x01feabcd is binary
  337.     
  338.         ----7--- ----7---- ---6--- ------12-------  bits 
  339.         0000 000|1 1111 11|10 1010| 1011 1100 1101
  340.         \_______/\________/\______/\_____________/
  341.             |         |          |              |
  342.             |         |          |              |
  343.             V         |          |              |
  344.         Index into level A of the MMU tree is 0, hence the first pointer
  345.         is read. The MMU obtains now another array of pointers, called
  346.         the level B. |          |              |
  347.                      |          |              |
  348.                      V          |              |
  349.                 Index into level B of the MMU tree is 127. The MMU uses
  350.                 the last pointer from the table obtained in the previous
  351.                 step.          |              |
  352.                               |              |
  353.                               V              |
  354.                         Index into level C of the MMU tree is 42. The MMU
  355.                         uses, hence, the 42nd pointer of the array pointed
  356.                         to by the 127th pointer of the level B array. This
  357.                         is now the "page descriptor", defining the base
  358.                         address for the next step.
  359.                                           |
  360.                                           |
  361.                                           V
  362.         This is now finally the page offset, 0xbcd in this example. It
  363.         is added to the base address from the page descriptor in level C.
  364.         If the address is not "remapped", the base address would be
  365.         identically to the first 32-12 = 20 bits of the physically address.
  366.         
  367.  
  368.         MCXTAG_DEPTH    -    Depth of the MMU tree to build. Defaults to
  369.                             the depth of the global public context.
  370.  
  371.                             Legal values are 1..4 for the 68020/68851 and
  372.                             the 68030, but the 68040/68060 supports only
  373.                             trees of depth 3.
  374.  
  375.         MCXTAG_LEVELABITS -    Number of bits of the logical address that make
  376.                             up the level A of the MMU tree. 2^bits is the
  377.                             number of entries on this level of the tree.
  378.  
  379.                             The 68020/68851 and the 68030 support here
  380.                             values from 1..15, the only legal value for
  381.                             the 68040 and 68060 is 7. 
  382.  
  383.                             The MMU library will pick a reasonable and
  384.                             system dependent default for you if you don't
  385.                             specify this tag item.
  386.  
  387.         MCXTAG_LEVELBBITS -    Number of bits for the level B of the MMU tree,
  388.                             unused if the depth is smaller than two.
  389.  
  390.                             Legal values are 1..15 for the 851 and 030, and
  391.                             7 as only possible value for the 040 and 060.
  392.  
  393.         MCXTAG_LEVELCBITS - Number of bits of the level C of the MMU tree,
  394.                             unused if the depth is smaller than three.
  395.  
  396.                             Arguments may range from 1..15 for the 851 and
  397.                             030, and must be either 5 or 6 for the 040 and
  398.                             060.
  399.  
  400.         MCXTAG_LEVELDBITS -    Number of bits in the level D of the MMU tree,
  401.                             only used if the depth is four and therefore
  402.                             unused on the 040 and 060. 
  403.  
  404.                             Must range from 1..15.
  405.  
  406.         MCXTAG_PAGEBITS -    Number of bits to be used from the logical
  407.                             address as the page offset. 2^bits is the
  408.                             page size. 
  409.  
  410.                             Legal values are 8..15, giving 256 bytes up
  411.                             to 32K pages for the 68020/68851 and 68030, or
  412.                             12..13 defining 4K resp. 8K pages for the
  413.                             68040 and 68060. 
  414.  
  415.                             The default is the page size of the global 
  416.                             context.
  417.  
  418.         All the "..."BITS specifications MUST sum up to 32 since a logical
  419.         address consists of exactly 32 bits. You may leave out some or all 
  420.         of these tags, the MMU library will keep care of the rest and will
  421.         chose reasonable defaults for you.
  422.  
  423.  
  424.         MCXTAG_ERRORCODE -    pointer to a ULONG the MMU library will fill
  425.                             in with an error code in case building the
  426.                             MMU tree failed. It will be set to 0L if the
  427.                             function succeeds. The following error codes
  428.                             have been defined:
  429.  
  430.             CCERR_NO_FREE_STORE -        the library went out of memory.
  431.             CCERR_INVALID_PARAMETERS -    the parameters specified by the 
  432.                                         tags are invalid.
  433.             CCERR_UNSUPPORTED -         the parameters are valid, but 
  434.                                         not supported by the hardware.
  435.             CCERR_TRIMMED      -            the library performed some minor
  436.                                         adjustments on the MMU table passed
  437.                                         in for cloning. The cache modes
  438.                                         might not be optimal due to some
  439.                                         roudings that have to be performed,
  440.                                         but the MMU table should work in
  441.                                         general.
  442.  
  443.                                         THIS IS NOT AN ERROR, you will get
  444.                                         your new context.
  445.  
  446.             CCERR_UNALIGNED      -            the library had to perform heavy
  447.                                         rouding in the MMU table passed
  448.                                         in, it might be unusable. For 
  449.                                         example, remapped pages were mis-
  450.                                         aligned and due to the rounding
  451.                                         accesses might go to wrong 
  452.                                         locations. If you get this return
  453.                                         code, you should possibly deallocate
  454.                                         the new context and inform the user
  455.                                         that the request could not be satis-
  456.                                         fied.
  457.  
  458.                                         Still, THIS IS NOT AN ERROR. You
  459.                                         get a new context, but possibly an
  460.                                         usuable one.
  461.  
  462.     RETURNS
  463.         NULL if the new context couldn't be created or a handle to the
  464.         new context, as parameter to all MMU library functions.
  465.  
  466.     NOTES
  467.         This call makes NOT the current task entering the new context,
  468.         you've to call EnterMMUContext() explicitly for that purpose.
  469.  
  470.         The context structure is not documented intentionally. It depends
  471.         on the implementation.
  472.  
  473.     BUGS
  474.  
  475.     SEE ALSO
  476.         DeleteMMUContext()
  477.  
  478.     BUGS
  479.  
  480. mmu.library/DeleteMMUContext                    mmu.library/DeleteMMUContext
  481.     
  482.     NAME
  483.         DeleteMMUContext - delete an MMU context build with CreateMMUContext.
  484.  
  485.     SYNOPSIS
  486.         DeleteMMUContext ( context );
  487.                             a0
  488.  
  489.         void DeleteMMUContext ( struct MMUContext * );
  490.  
  491.     FUNCTION
  492.         This function deletes a context build with CreateMMUContext().
  493.  
  494.  
  495.     INPUTS     
  496.         A handle to the context to be deleted.
  497.  
  498.     RETURNS
  499.         nothing.
  500.  
  501.     NOTES
  502.         This call doesn't remove any task from the context, especially the
  503.         current task is NOT removed from the context. You've to call
  504.         LeaveMMUContext() before.
  505.  
  506.         Deleting a context with some tasks still in this context will
  507.         cause this function to guru.
  508.  
  509.         If your context was created with a private supervisor context
  510.         included, you must call this function only *once*, with the
  511.         user context created. It will automatically deallocate the
  512.         attached supervisor context as well.
  513.  
  514.     BUGS
  515.  
  516.     SEE ALSO
  517.         CreateMMUContext()
  518.  
  519. mmu.library/EnterMMUContext                        mmu.library/EnterMMUContext
  520.  
  521.     NAME
  522.         EnterMMUContext - let a task enter a specific context.
  523.  
  524.     SYNOPSIS
  525.         context = EnterMMUContext( context , task );
  526.         d0                               a0         a1
  527.  
  528.         struct MMUContext * EnterMMUContext( struct MMUContext * , 
  529.                     
  530.                                     struct Task * );
  531.  
  532.     FUNCTION
  533.         Add a given task to a context. This makes the MMU settings defined
  534.         by the context available for the task in question.
  535.  
  536.     INPUTS
  537.         context - the context to enter or NULL for the global context.
  538.         task    - a pointer to the task structure that should enter the
  539.                   context.
  540.  
  541.     RETURNS
  542.         a handle to the context the task participated before or NULL if
  543.         this function failed. The task will stay in the last context used
  544.         in this case.
  545.  
  546.     NOTES
  547.         This call uses the tc_Switch() and tc_Launch() functions of the
  548.         task structure. What basically happens here is that these functions
  549.         are set to internal procedures that swap the context specific
  550.         MMU table or the global MMU in and flush the ATC of the MMU.
  551.  
  552.         This call may fail, check the return code for NULL - either due to
  553.         lack of memory or because the task is part of a protected context
  554.         the current task hasn't entered.
  555.  
  556.         If you want to use the tc_Switch() and tc_Launch() functions your-
  557.         self, you should install a task specific context hook, see 
  558.         AddContextHook().
  559.  
  560.         This function can be used to change the context of a task by
  561.         adding it to a new context. The task specific context switch and
  562.         launch hooks will be "carried over" to the new context, but all
  563.         other MMU specific exceptions are now the matter of the new context.
  564.  
  565.     BUGS
  566.  
  567.     SEE ALSO
  568.         LeaveMMUContext(),ProtectMMUContext(), exec/tasks.h
  569.  
  570. mmu.library/LeaveMMUContext                        mmu.library/LeaveMMUContext
  571.     
  572.     NAME
  573.         LeaveMMUContext - remove a given task from a context.
  574.  
  575.     SYNOPSIS
  576.         context = LeaveMMUContext( task );
  577.         d0                        a1
  578.  
  579.         struct MMUContext * LeaveMMUContext( struct Task *);
  580.  
  581.     FUNCTION
  582.         The specified task leaves its context and enters the global context.
  583.  
  584.     INPUTS
  585.         task - the task that should leave a private context and enter the
  586.             global default context.
  587.  
  588.     RETURNS
  589.         the context the task was added to or NULL on failure.
  590.         Might be the global default context if the task did not enter any 
  591.         context.
  592.  
  593.     NOTES
  594.         It is safe to call this function even if the task wasn't added to
  595.         any context. The function returns the global context in this case.
  596.  
  597.         This function must be called to any task participating a given
  598.         context to be able to delete that context.
  599.  
  600.         This function is equivalent to EnterMMUContext(NULL,task). 
  601.  
  602.         This function makes use of the tc_Switch() and tc_Launch() functions
  603.         of the task structure to be able to set the MMU root pointer.
  604.  
  605.         Make sure that you check for failure. This call may return NULL if
  606.         the task entered a protected context the current task does not
  607.         participate or if switch and launch exceptions are in use.
  608.  
  609.     BUGS
  610.  
  611.     SEE ALSO
  612.         EnterMMUContext(), DeleteMMUContext(), ProtectMMUContext(), 
  613.         RemContextHook(), exec/tasks.h
  614.  
  615. mmu.library/CurrentContext                            mmu.library/CurrentContext
  616.  
  617.     NAME
  618.         CurrentContext - find out the current context of a task.
  619.  
  620.     SYNOPSIS
  621.         context = CurrentMMUContext( task );
  622.         d0                          a1
  623.  
  624.         struct MMUContext * CurrentMMUContext( struct Task * );
  625.  
  626.     FUNCTION
  627.         This function is used to get a handle to the context the given
  628.         task is added to, or to return the context of the calling task.
  629.  
  630.     INPUTS
  631.         task - the address of the task structure you like to investigate
  632.         or NULL to get a handle to the currently active context.
  633.  
  634.     RETURNS
  635.         a handle to the context the given task is added to, the global
  636.         context if the task is not attached to any context or the
  637.         currently active context if the argument is NULL. 
  638.  
  639.     NOTES
  640.         This call fails only if the given task is part of a protected
  641.         context which is not shared by the current task. The NULL
  642.         argument is always safe.
  643.  
  644.     BUGS
  645.         Protected contexts are not yet implemented.
  646.  
  647.     SEE ALSO
  648.         ProtectMMUContext(), FindTask()
  649.  
  650. mmu.library/AddContextHook                            mmu.library/AddContextHook
  651.  
  652.     NAME
  653.         AddContextHook - set an exception handler to a Context
  654.  
  655.     SYNOPSIS
  656.         hook = AddContextHookA ( tags );
  657.                                   a0
  658.  
  659.         hook = AddContextHook ( tag1, ... );
  660.  
  661.         
  662.         struct ExceptionHook * AddContextHookA ( struct TagItem * );
  663.  
  664.         struct ExceptionHook * AddContextHook ( Tag tag1, ... );
  665.  
  666.     FUNCTION
  667.         This call installs an exception hook for a given context for
  668.         various exception types the MMU library can provide.
  669.  
  670.     INPUTS
  671.         tags     -    A taglist defining the type of the exception hook
  672.                     to be added.
  673.  
  674.         Currently defined are:
  675.  
  676.         MADTAG_CONTEXT        -    The context to which this exception hook
  677.                                 should be added. This MUST be given for
  678.                                 "swapped" handlers. If it is left blank
  679.                                 or set to NULL for segmentation fault
  680.                                 handlers, you define a global segmentation
  681.                                 fault handler.
  682.  
  683.         MADTAG_TASK            -    If the hook should be called only if a
  684.                                 specific task is running, specify a pointer
  685.                                 to the task structure here. 
  686.                                 Warning! Adding too many task specific
  687.                                 hooks slows things down unnecessary.
  688.                                 Remember that a MMU Context may hold more
  689.                                 than one task.
  690.                                 This MUST be given for the switch and launch
  691.                                 hooks.
  692.  
  693.         MADTAG_TYPE            -    Type of the exception hook to build. The
  694.                                 following types are available:
  695.  
  696.             MMUEH_SEGFAULT    -    Called on segmentation fault, i.e. write to
  697.                                 a write protected page or access of an
  698.                                 invalid page. Most useful for "Enforcer"
  699.                                 like tools.
  700.  
  701.             MMUEH_SWAPPED    -    Called on access for a "swapped out" page.
  702.                                 Most useful to implement virtual memory.
  703.  
  704.             MMUEH_SWITCH    -    Called when the task looses the CPU.
  705.             MMUEH_LAUNCH    -    Called when the task gains the CPU.
  706.                                 Remember that the tc_Switch() and tc_Launch()
  707.                                 function pointers are no longer available
  708.                                 if the task has been added to a MMUContext.
  709.  
  710.             MMUEH_PAGEACCESS -    Called whenever a MAPP_SINGLE page gets
  711.                                 build by the context. This could be used to
  712.                                 modify the MMU tree "on the fly" if 
  713.                                 necessary, the required parameters are passed
  714.                                 thru.
  715.  
  716.         MADTAG_CODE            -    A function pointer to the code to be called.
  717.                                 This should be an assembly language function.
  718.                                 It is called like this:
  719.  
  720.         Register a0            -    Pointer to the ExceptionData structure or
  721.                                 the PageAccessData.
  722.         Register a1            -    loaded with the MADTAG_DATA provided data.
  723.         Register a4            -    Ditto.
  724.         Register a5            -    Pointer to the code itself.
  725.         Register a6            -    MMUBase. NOT A SCRATCH.
  726.  
  727.         Registers d0-d1/a0-a1/a4-a5 are scratches and are available for the
  728.         Exception handler. You *MUST* set the "Z" condition code and
  729.         clear d0 on exit in case you handled the exception. Details on
  730.         how to write an exception handler are in the "Exception.doc" file.
  731.  
  732.         MADTAG_DATA            -    Data to be loaded for the hook function.
  733.         MADTAG_NAME            -    A name for the hook. Currently unused.
  734.         MADTAG_PRI            -    A priority, ranging from -128...+127.
  735.                                 Hooks of higher priorities are called first.
  736.  
  737.     RESULTS
  738.         A handle to the exception hook. Do not interpret this handle.
  739.         Or NULL on failure.
  740.  
  741.     NOTES
  742.         this call will be used by the high-level function AddMessageHook().
  743.         The global segmentation fault hook may be set by a debugging tool 
  744.         like the enforcer.
  745.  
  746.         The exception will not be activated, you need to call 
  747.         ActivateException() explicitly to make the library call it.
  748.  
  749.         Much more needs to be said about this function, see Exception.doc
  750.         for details about the exception handlers.
  751.  
  752.     BUGS
  753.  
  754.     SEE ALSO
  755.         RemContextHook(), AddMessageHook(), ActivateException(),
  756.         exec/interrupts.h, Exception.doc
  757.  
  758. mmu.library/RemContextHook                            mmu.library/RemContextHook
  759.  
  760.     NAME
  761.         RemContextHook - remove an exception handler from a Context
  762.  
  763.     SYNOPSIS
  764.         RemContextHook( hook )
  765.                          a1
  766.  
  767.         void RemContextHook( struct ExceptionHook * );
  768.  
  769.     FUNCTION
  770.         This function removes a previously installed context hook
  771.         from the hook list.
  772.  
  773.     INPUTS
  774.         The handle of the hook, as obtained by AddContextHook().
  775.  
  776.     RESULTS
  777.         none.
  778.  
  779.     NOTES
  780.         You must call DeactivateException() on your hook before you
  781.         remove it.
  782.         Be aware that the library will call the exec exception handler,
  783.         i.e. will generate a guru in case no exception handler is
  784.         available.
  785.  
  786.     SEE ALSO
  787.         AddContextHook(), DeactivateException(), exec/interrupts.h
  788. mmu.library/AddMessageHook                            mmu.library/AddMessageHook
  789.  
  790.     NAME
  791.         AddMessageHook - install a high-level hook function.
  792.  
  793.     SYNOPSIS
  794.         hook = AddMessageHookA ( tags );
  795.                                   a0
  796.  
  797.         hook = AddMessageHook ( tag1, ... );
  798.  
  799.  
  800.         struct ExceptionHook * AddMessageHookA ( struct TagItem * );
  801.  
  802.         struct ExceptionHook * AddMessageHook ( Tag tag1, ... );
  803.  
  804.     FUNCTION
  805.         Installs a high-level hook of the tag-given properties.
  806.         As soon as an exception of the requested type occurs, an exception 
  807.         message (see below) will be sent to the port. The task that caused 
  808.         the exception will be halted until the message gets replied.
  809.         BE WARNED: Message hooks perform only operation if task switching
  810.         is enabled and interrupts are allowed and the code failed in
  811.         User mode. They will just "drop thru" to the next handler if this 
  812.         is not the case.
  813.  
  814.     INPUTS
  815.         tags     -    A taglist defining the type of the exception hook
  816.                     to be added.
  817.  
  818.         Currently defined are:
  819.  
  820.         MADTAG_CONTEXT        -    The context to which this exception hook
  821.                                 should be added. This MUST be given.
  822.  
  823.         MADTAG_TASK            -    If the hook should be called only if a
  824.                                 specific task is running, specify a pointer
  825.                                 to the task structure here. 
  826.                                 Warning! Adding too many task specific
  827.                                 hooks slows things down unnecessary.
  828.                                 Remember that a MMU Context may hold more
  829.                                 than one task.
  830.                                 This MUST be given for the switch and launch
  831.                                 hooks.
  832.  
  833.         MADTAG_TYPE            -    Type of the exception hook to build. The
  834.                                 following types are available:
  835.  
  836.             MMUEH_SEGFAULT    -    Called on segmentation fault, i.e. write to
  837.                                 a write protected page or access of an
  838.                                 invalid page. Most useful for "Enforcer"
  839.                                 like tools.
  840.  
  841.             MMUEH_SWAPPED    -    Called on access for a "swapped out" page.
  842.                                 Most useful to implement virtual memory.
  843.  
  844.         MADTAG_CATCHERPORT    -    The port to sent the data to.
  845.         MADTAG_NAME            -    A name for the hook. Currently unused.
  846.         MADTAG_PRI            -    A priority, ranging from -128...+127.
  847.                                 Hooks of higher priorities are called first.
  848.  
  849.         On an exception, the following message will be sent to the port:
  850.  
  851.         struct ExceptionMessage {
  852.             struct Message            exm_msg;
  853.             struct ExceptionData     exm_Data;
  854.         };
  855.  
  856.         For details about the ExceptionData structure, see Exception.doc.
  857.  
  858.         Once the message gets replied, the faulted task is restarted.
  859.  
  860.     RESULTS
  861.         a handle for the exception that must be passed back to 
  862.         RemMessageHook() for removal or NULL on failure.
  863.         Do not interpret this handle.
  864.         
  865.     NOTES
  866.         The handler must have been added to a context with EnterMMUContext()
  867.         before this function can be used. Unlike the AddContextHook() 
  868.         function, this DOES NOT work for "plain" tasks without a context.
  869.  
  870.         The hook must be activated with ActivateException() before it 
  871.         gets called.
  872.  
  873.         This function is used by the memory.library to install its
  874.         exception handler. The port will be in this case the port of
  875.         the swapper daemon that loads swapped out pages from disk.
  876.  
  877.     BUGS
  878.         
  879.     SEE ALSO
  880.         AddContextHook(), RemContextHook(), RemMessageHook(), 
  881.         ActivateException(), Exception.doc
  882.  
  883. mmu.library/RemMessageHook                            mmu.library/RemMessageHook
  884.  
  885.     NAME
  886.         RemMessageHook    -    remove a high-level hook from a context.
  887.  
  888.     SYNOPSIS
  889.         RemMessageHook( handle );
  890.                          a1
  891.  
  892.         void RemMessageHook( struct ExceptionHook * );
  893.  
  894.  
  895.     FUNCTION
  896.         This function removed a previously installed Message hook from
  897.         the hook list of the context.
  898.  
  899.     INPUTS
  900.         handle - a handle to the message hook as returned by the 
  901.             AddMessageHook function.
  902.  
  903.     RESULTS
  904.         none.
  905.  
  906.     NOTES
  907.         To remove a message hook safely, deactivate it first with
  908.         DeactivateException(), then tell the daemon to reply all 
  909.         exceptions of this hook, then remove it. 
  910.  
  911.         Not following these rules may cause deadlocks.
  912.     
  913.     BUGS
  914.         
  915.     SEE ALSO
  916.         AddMessageHook(), AddContextHook(), RemContextHook(),
  917.         DeactivateException(), Exception.doc
  918.  
  919. mmu.library/ActivateException                    mmu.library/ActivateException
  920.  
  921.     NAME
  922.         ActivateException    -    enable an exception hook.
  923.  
  924.     SYNOPSIS
  925.         ActivateException( hook );
  926.                             a1
  927.  
  928.         void ActivateException( struct ExceptionHook * );
  929.  
  930.     FUNCTION
  931.         Activates a formerly installed exception hook, either a low
  932.         level context hook or a high-level message hook.
  933.     
  934.     RETURNS
  935.         
  936.     NOTES
  937.         Hooks of either kind must be activated before the mmu.library
  938.         will call them. Hooks are deactivated after creation and must
  939.         be deactivated before they get removed.
  940.         This call can be safely used within interrupts and from super-
  941.         visor mode.
  942.  
  943.     BUGS
  944.  
  945.     SEE ALSO
  946.         DeactivateException(), AddContextHook(), AddMessageHook(),
  947.         Exception.doc
  948.  
  949. mmu.library/DeactivateException                mmu.library/DeactivateException
  950.  
  951.     NAME
  952.         DeactivateException    -    enable an exception hook.
  953.  
  954.     SYNOPSIS
  955.         DeactivateException( hook );
  956.                             a1
  957.  
  958.         void DeactivateException( struct ExceptionHook * );
  959.  
  960.     FUNCTION
  961.         Deactivates a formerly installed exception hook, either a low
  962.         level context hook or a high-level message hook, i.e. disables
  963.         it from being called.
  964.     
  965.     RETURNS
  966.         
  967.     NOTES
  968.         Hooks of either kind must be activated before the mmu.library
  969.         will call them. Hooks are deactivated after creation and must
  970.         be deactivated before they get removed.
  971.         This call can be safely used within interrupts and from super-
  972.         visor mode.
  973.  
  974.     BUGS
  975.  
  976.     SEE ALSO
  977.         ActivateException(), RemContextHook(), RemMessageHook(),
  978.         Exception.doc
  979.  
  980. mmu.library/GetPageSize                                mmu.library/GetPageSize
  981.  
  982.     NAME
  983.         GetPageSize - return the page size of a context.
  984.  
  985.     SYNOPSIS
  986.         pagesz = GetPageSize( context );
  987.         d0                      a0
  988.  
  989.         ULONG GetPageSize( struct MMUContext * );
  990.  
  991.     FUNCTION
  992.         This function returns the page size selected by the MMU library for
  993.         the given context. Possible page sizes are limited by the hardware
  994.         and cannot be adjusted from the outside. The page size is set up
  995.         by the MMU library for the global public context, and it can be
  996.         selected from the available page sizes for private MMUContexts, see
  997.         CreateMMUContext().
  998.  
  999.     INPUTS
  1000.         context - a handle to the context to be investigated or NULL for
  1001.             the active context.
  1002.  
  1003.     RESULTS
  1004.         the page size in bytes or zero for failure.
  1005.  
  1006.     NOTES
  1007.  
  1008.     BUGS
  1009.         Context protection is currently unsupported.
  1010.  
  1011.     SEE ALSO
  1012.         CreateMMUContext()
  1013.  
  1014. mmu.library/RemapSize                                mmu.library/RemapSize
  1015.  
  1016.     NAME
  1017.         RemapSize - return the block size for memory remapping.
  1018.  
  1019.     SYNOPSIS
  1020.         remapsize = RemapSize( context );
  1021.         d0                         a0
  1022.  
  1023.         ULONG RemapSize( struct MMUContext * );
  1024.  
  1025.     FUNCTION
  1026.         This function returns the smallest possible block size, and
  1027.         therefore the alignment restrictions, for remapping of memory that
  1028.         should be added to the exec memory pool. Since the MMU tables have
  1029.         to be placed in non-fragmented memory, certain alignment 
  1030.         restrictions for the memory blocks the MMU tables are placed in
  1031.         arise. 
  1032.         This harder aligment condition is only required for memory
  1033.         that is put into the exec free list, but as long as remapped
  1034.         memory is never returned from AllocMem, the page size is good 
  1035.         enough.
  1036.  
  1037.     INPUTS
  1038.         context - a handle to the context to be investigated or NULL for
  1039.             the active context.
  1040.  
  1041.     RESULTS
  1042.         the smallest admissable block size for memory returned by 
  1043.         AllocMem().
  1044.  
  1045.     NOTES
  1046.         The call will fail if the given context is protected, the result
  1047.         will be zero in this case.
  1048.  
  1049.         Even though the mmu.library does support memory remapping, this
  1050.         does not mean all other programs do. For example, remember that
  1051.         the inputs to the "MAPP_REMAPPED" pages is a physical page size,
  1052.         hence your program has to translate the logical address obtained
  1053.         by AllocMem() to a physical address at first. This can be done 
  1054.         with the PhysicalLocation() function.
  1055.         
  1056.         Additionally, DMA devices might or might not support memory
  1057.         remapping, just for the same reason: They require physical, not
  1058.         logical addresses. The MMU library provides a translation mechanism
  1059.         in form of the ChachePreDMA() and CachePostDMA() functions of
  1060.         ExecBase, but not all DMA device drivers call these functions
  1061.         properly. Certain patches might be made available for devices
  1062.         not following this rule.
  1063.  
  1064.     BUGS
  1065.         Adding remapped memory to the freelist is highly untested and
  1066.         not recommended because of the quirks of this mechanism.
  1067.  
  1068.     SEE ALSO
  1069.         PhysicalLocation(), GetPageSize(), exec/CachePreDMA(),
  1070.         DMAInitiate()
  1071.  
  1072. mmu.library/SetPropertiesA                        mmu.library/SetPropertiesA
  1073.  
  1074.     
  1075.     NAME
  1076.         SetPropertiesA - set memory attributes for a given logical range.
  1077.  
  1078.     SYNOPSIS
  1079.  
  1080.         result = SetPropertiesA( context, flags, mask, lower, size, tags);
  1081.         d0                         a0          d1     d2    a1        d0      a2
  1082.  
  1083.         BOOL SetPropertiesA( struct MMUContext *, ULONG, ULONG, ULONG, ULONG,
  1084.                              struct TagItem *);
  1085.  
  1086.  
  1087.         result = SetProperties( context, flags, mask, lower, size, tag1, ...);
  1088.  
  1089.         BOOL SetProperties( struct MMUContext *, ULONG, ULONG, ULONG, ULONG,
  1090.                             Tag tag1, ...);
  1091.  
  1092.     FUNCTION
  1093.         This call sets attributes of a certain memory range of the
  1094.         software abstraction layer of the MMU tree, aligned to page 
  1095.         boundaries.
  1096.  
  1097.     INPUTS
  1098.         context - a handle to the context to modify or NULL for the active
  1099.             context.
  1100.  
  1101.         flags    - a binary flags field for the attributes to define. The
  1102.                 following bits have been defined:
  1103.  
  1104.                 MAPP_WRITEPROTECTED     -    The page will be write 
  1105.                     protected. Writes to this area will cause a segmentation
  1106.                     fault.
  1107.  
  1108.                 MAPP_ROM                - Read only memory, writes tolerated.
  1109.                     This is almost identically to MAPP_READONLY except that
  1110.                     writes into this area will not cause a call of the
  1111.                     segmentation fault handler. The library will filter them
  1112.                     out.
  1113.                     This property can be used to simulate a ROM in RAM and
  1114.                     might be useful for kickstart remappers.
  1115.  
  1116.                 MAPP_USED                -    The "used" bit of the pages
  1117.                     will be set. The CPU will set this bit automatically
  1118.                     as soon as the pages are accessed.
  1119.  
  1120.                     This flag will turn on the "USED" bit in the hard-
  1121.                     ware MMU bit. NOT setting this flag means that the
  1122.                     USED bit in the hardware tree is preserved, regard-
  1123.                     less of the mask value.
  1124.  
  1125.                 MAPP_MODIFIED            -    The "modified" bit of the pages
  1126.                     will be set. The CPU will set this bit automatically
  1127.                     as soon as a write is performed to the page in question.
  1128.                     DO NOT SET THIS BIT TOGETHER WITH MAPP_WRITEPROTECTED
  1129.                     OR WITHOUT MAPP_USED or the CPU might hang. 
  1130.  
  1131.                     This flag will turn on the "MODIFIED" bit in the hard-
  1132.                     ware MMU bit. NOT setting this flag means that the
  1133.                     MODIFIED bit in the hardware tree is preserved, regard-
  1134.                     less of the mask value.
  1135.  
  1136.                 MAPP_PRIVATE            -    The page will be marked invalid
  1137.                     for all but the given contexts.
  1138.  
  1139.                 MAPP_INVALID            -    The page will be marked as 
  1140.                     invalid. Accessing it will invoke the bus error hook.
  1141.                     User data can be provided for this property mode,
  1142.                     provided you don't select MAPP_SINGLEPAGE or 
  1143.                     MAPP_REPAIRABLE as well.
  1144.  
  1145.                 MAPP_SWAPPED            -    The page will be marked as
  1146.                     swapped out.
  1147.                     A block ID *MUST* be provided for this property mode.
  1148.  
  1149.                 MAPP_CACHEINHIBIT        -    The page will be marked as non-
  1150.                     cacheable.
  1151.  
  1152.                 MAPP_IMPRECISEEXECPTION    -    The page will be marked as 
  1153.                     "imprecise exception". MAPP_CACHEINHIBIT is mandatory
  1154.                     in this case or this flag does nothing.
  1155.                     Only available for the 68060, but does not harm for
  1156.                     other MMUs.
  1157.  
  1158.                 MAPP_NONSERIALIZED        -    The page will be marked as
  1159.                     serialized. MAPP_CACHEINHIBIT is mandatory if this
  1160.                     property is selected. 
  1161.                     Only available for the 68040, but does not harm for
  1162.                     other MMUs.
  1163.  
  1164.                 MAPP_COPYBACK            -    The page will be marked as
  1165.                     "copyback" instead of "writethrough". Generally re-
  1166.                      commended since this is faster for the '40 and '60.
  1167.                     Only available for 68040 and 68060, but does not harm
  1168.                     if selected for other MMUs. MAPP_CACHINHIBIT MUST NOT
  1169.                     be selected.
  1170.     
  1171.                 MAPP_REMAPPED                -    Map the page to a different
  1172.                     memory location. Parameters are given in the tag items.
  1173.  
  1174.                     Even though this seems simple, remapping memory is
  1175.                     full of quirks. Obviously, DMA devices and the MMU
  1176.                     itself see the true physical addresses and not the
  1177.                     logical addresses as filtered by the MMU. Therefore,
  1178.                     adding remapped memory to the exec.library freelist
  1179.                     will cause nothing than trouble and hard to trace
  1180.                     disk faults and crashes as soon as this memory is
  1181.                     used by a DMA device or the mmu.library itself.
  1182.                     (Note that even though the library is supposed to
  1183.                      support this, this is currently untested)
  1184.                     Even though there *are* documented methods how to
  1185.                     prepare a DMA transfer for remapped memory, USING
  1186.                     these exec function calls is unfortunately the 
  1187.                     exceptions. Therefore, this method is currently un-
  1188.                     supported, by most (!really!) DMA device drivers. 
  1189.                     Amongst the broken devices are the gvpscsi.device 
  1190.                     and the cybscsi.device, to give just two examples.
  1191.  
  1192.                     The omniscsi.device (the "Guru ROM") can be fixed
  1193.                     with the MuOmniScsiPatch.
  1194.  
  1195.                     If you really *MUST* remap public memory, then align
  1196.                     it *AT LEAST* to the border given by RemapSize().    
  1197.                     Just page alignment WILL NOT BE ENOUGH due to the way
  1198.                     how the library works internally.    
  1199.  
  1200.                     YOU HAVE BEEN WARNED!
  1201.                     
  1202.                 MAPP_SUPERVISORONLY        -    The page will be not available
  1203.                     for user programs.
  1204.  
  1205.                     NOTE: This mode is currently implemented using invalid 
  1206.                     page descriptors for the user pages and is ignored
  1207.                     when building supervisor tables. This method saves some
  1208.                     space for the 68040 and 68060 and was the only way how
  1209.                     it could be done for the 68030 and 68851 without using
  1210.                     MMU tables twice as large.
  1211.  
  1212.                 MAPP_USERPAGE0            -    Set user page attribute 0.
  1213.                     This selects the user page attribute 0 for the 68040
  1214.                     and 68060. "USER" DOES NOT MEAN YOU!
  1215.                     The status of this bit appears on special pins of the
  1216.                     CPU and might be required by some hardware, so don't     
  1217.                     play with this. You should not change this bit, by no
  1218.                     means.
  1219.  
  1220.                 MAPP_USERPAGE1            -    Set user page attribute 1.
  1221.                     This selects the user page attribute 0 for the 68040
  1222.                     and 68060. See above for warnings.
  1223.  
  1224.                 MAPP_GLOBAL                -    The pages are part of the
  1225.                     global (public) memory. 
  1226.                     You should not set this bit manually, it is under
  1227.                     control of the library to optimize table flushes.
  1228.  
  1229.                 MAPP_BLANK                -    Blank memory.
  1230.                     The pages are mapped to one special area in RAM so
  1231.                     erraneous reads and writes to these pages won't harm. 
  1232.                     MAPP_BLANK should ONLY be used to mark special memory
  1233.                     areas as "non-available" and un-handled by the hardware,
  1234.                     nothing else. 
  1235.  
  1236.                 MAPP_SHARED                -     Properties are identically to
  1237.                     the public context.
  1238.                     This tells the library to use the same properties as
  1239.                     for the global context. However, MAPP_SHARED pages
  1240.                     are not automatically updated when the global context
  1241.                     changes, it's just a convenient way of saying "I want
  1242.                     to uninstall my settings".
  1243.  
  1244.                 MAPP_TRANSLATED            -    Under control of the TTx 
  1245.                     registers.
  1246.                     NEVER SET THIS BIT YOURSELF.
  1247.                     Pages with the "MAPP_TRANSLATED" bit set are under
  1248.                     control of the "transparent translation registers" of
  1249.                     the MMU and are "out of scope" for the mmu.library.
  1250.                     Defining any properties for this domain will do nothing
  1251.                     (or little, dependent on the TTx register configuration).
  1252.                     A virtual memory program MUST NOT use virtual addresses
  1253.                     which are transparently translated, this won't work.
  1254.                     The mmu.library tries to be smart about the TTx registers
  1255.                     and disables "unuseful" TTx settings itself.
  1256.  
  1257.                 MAPP_INDIRECT            -     Map to a user provided page
  1258.                     descriptor.
  1259.                     The provided pages(s) are mapped by a user provided
  1260.                     page descriptor. This page descriptor MUST BE aligned
  1261.                     to a long word address, and it MUST BE a valid page
  1262.                     descriptor for the MMU used.
  1263.  
  1264.                     NEVER EVER attempt DMA, such as harddisk reads or
  1265.                     writes to a memory domain marked as MAPP_INDIRECT.
  1266.  
  1267.                     Due to some cache peculatities, the data might be
  1268.                     incorrect and the result would be corrupt data.
  1269.  
  1270.                     The library will be able to mark pages as non-cacheable
  1271.                     if this is required for the DMA transfer, but this
  1272.                     magic does not work for indirect pages.
  1273.  
  1274.                     JUST DON'T DO THAT, MAPP_INIDIRECT is definitely an
  1275.                     advanced feature.
  1276.  
  1277.                 MAPP_BUNDLED            -    Map all pages in range to
  1278.                     a single page in RAM.
  1279.  
  1280.                     The main purpose of this function is to provide a
  1281.                     MAPP_BLANK property with a user-selectable target
  1282.                     page.
  1283.  
  1284.                 MAPP_SINGLEPAGE            -    Make this page available for
  1285.                     SetPagePropertiesA().
  1286.  
  1287.                     WARNING! Setting this bit shortcuts some optimizations
  1288.                     the library might perform on the MMU table. The system
  1289.                     may easely run out of memory if you select this
  1290.                     property for "too many" pages. Use it with care, you
  1291.                     have been warned!
  1292.  
  1293.                 MAPP_REPAIRABLE            -    Inform the exception handler
  1294.                     to provide write data and to allow pipeline fill.
  1295.  
  1296.                     If this bit is set, the exception handler gets informed
  1297.                     that you want to know the write data in case writes
  1298.                     fail, or you want to provide the read data in case
  1299.                     reads fail. The read/write data is available in the
  1300.                     ExceptionData structure, read the exception handler
  1301.                     documentation.
  1302.  
  1303.                     This flag should be combined with MAPP_INVALID,
  1304.                     MAPP_WRITEPROTECTED, MAPP_SWAPPED or 
  1305.                     MAPP_SUPERVISORONLY
  1306.  
  1307.                     However, this technique requires a lot of "trickery"
  1308.                     and should be expected to be slow and to create
  1309.                     sub-optimal and over-sized MMU tables. Use it with
  1310.                     care, on as few pages as possible and only if your
  1311.                     exception handler is "not on a hurry".
  1312.  
  1313.                 MAPP_USERATTRIBUTE0        -    This is for your private use.
  1314.                     This bit does not have any specific function, it is
  1315.                     for your private use.
  1316.  
  1317.                 MAPP_USERATTRIBUTE1        -    This is for your private use.
  1318.                 MAPP_USERATTRIBUTE2
  1319.                 MAPP_USERATTRIBUTE3
  1320.  
  1321.  
  1322.         mask    -    A bit mask of the attributes to be changed.
  1323.  
  1324.                 Note that the hardware USED and MODIFIED bits will never
  1325.                 be cleared, even though the properties say so and the
  1326.                 corresponding bits in the mask are set. However, you can
  1327.                 force them "ON" if you like, this saves unnecessary write-
  1328.                 backs of the MMU.
  1329.         
  1330.         lower    -    The lower boundary of the logical address to be 
  1331.                 modified. This must be aligned to the page size or this call
  1332.                 will guru.
  1333.  
  1334.         size    -    Size of the region to be modified. Must be a multiple
  1335.                 of the page size.
  1336.  
  1337.         tags    -    A tag array with additional data. Currently defined:
  1338.  
  1339.                 MAPTAG_DESTINATION    -    the physical destination of the
  1340.                     logical address. Must be provided for the MAPP_MAPPED
  1341.                     or MAPP_BUNDLED    bits. 
  1342.  
  1343.                 MAPTAG_BLOCKID        -    a unique ID the MMU.library doesn't
  1344.                     care about, for external usage of the memory.library.
  1345.                     Must be provided for the MAPP_SWAPPED flag and may be
  1346.                     used to indicate where on disk the swapped page is
  1347.                     kept.
  1348.                 
  1349.                 MAPTAG_USERDATA        -    a unique cookie you might provide
  1350.                     for MAPP_INVALID pages and which is passed thru to the
  1351.                     segmentation fault exception handler.
  1352.  
  1353.                 MAPTAG_DESCRIPTOR    -    a pointer to a long word aligned
  1354.                     table descriptor for MAPP_INDIRECT.
  1355.                 
  1356.  
  1357.     RESULTS
  1358.         A boolean success/failure indicator. Might fail if the context
  1359.         is protected or no memory is available for the modification.
  1360.  
  1361.     NOTES
  1362.         This call adjusts only the abstraction layer of the MMU table
  1363.         and marks the pages as "dirty". An explicit call to 
  1364.         RebuildTree() is required to make the changes active.
  1365.         You should bundle changes to the MMU table and call RebuildTree()
  1366.         once when you're done because rebuilding the MMU tree is a costy
  1367.         operation.
  1368.         If you need to modify the MMU table "on the fly" then consider
  1369.         using "SetPagePropertiesA()", even though its use is restricted
  1370.         to single pages. Even faster are MAPP_INDIRECT pages, but - to
  1371.         say that again - DO NOT PERFORM DMA ON THESE PAGES.
  1372.  
  1373.         The page size can be read with GetPageSize(). 
  1374.  
  1375.         SUPERVISORONLY, SWAPPED and INVALID memory are implemented 
  1376.         using the same MMU attributes (invalid, namely), but the 
  1377.         library exception handler will filter them out and call 
  1378.         the appropriate hook.
  1379.  
  1380.         Write protection goes only for the context specified. It 
  1381.         usually makes sense to mark the memory region as PRIVATE as well, 
  1382.         unless you modify the public hook.
  1383.         (Note that MAPP_PRIVATE is currently not implemented because it
  1384.          will slow down things considerably.)
  1385.  
  1386.         You may freely mark the first memory page as INVALID provided
  1387.         the context MCXTAG_EXECBASE flag is set (it usually is).
  1388.         Long word read accesses to AbsExecBase will be filtered out by 
  1389.         the exception handler of the library and will be satisfied trans-
  1390.         parently to the program, as well as all other accesses except
  1391.         those into the first 1024 bytes.
  1392.  
  1393.     BUGS
  1394.  
  1395.         If the mask contains any property that requires user data, i.e.
  1396.         MAPP_REMAPPED or MAPP_SWAPPED, you *have* to redefine the user 
  1397.         data by tag items and MAY NOT leave them out, as the library 
  1398.         WILL NOT be able to restore the previously defined user data.
  1399.  
  1400.     SEE ALSO
  1401.         GetPropertiesA(), SetContextHook(), GetPageSize(), 
  1402.         RemapSize(), RebuildTree(), SetPagePropertiesA(),    
  1403.         SetMappingPropertiesA()
  1404.  
  1405. mmu.library/SetPagePropertiesA                mmu.library/SetPagePropertiesA
  1406.  
  1407.     NAME
  1408.         SetPagePropertiesA - set hardware memory attributes for a single
  1409.         page.
  1410.  
  1411.     SYNOPSIS
  1412.  
  1413.         result = SetPagePropertiesA( context, flags, mask, lower, tags);
  1414.         d0                               a0        d1      d2    a1        a2
  1415.  
  1416.         BOOL SetPagePropertiesA( struct MMUContext *, ULONG, ULONG, ULONG,
  1417.                              struct TagItem *);
  1418.  
  1419.  
  1420.         result = SetPageProperties( context, flags, mask, lower, tag1, ...);
  1421.  
  1422.         BOOL SetPageProperties( struct MMUContext *, ULONG, ULONG, ULONG, 
  1423.                             Tag tag1, ...);
  1424.  
  1425.     FUNCTION
  1426.         This call sets the hardware attributes of a memory page.
  1427.  
  1428.     INPUTS
  1429.         context - a handle to the context to modify or NULL for the active
  1430.             context.
  1431.  
  1432.         flags    - a binary flags field for the attributes to define. For
  1433.                     the available attributes, see the SetPropertiesA()
  1434.                     function.
  1435.  
  1436.                     Differences:
  1437.  
  1438.                     MAPP_MODIFIED and MAPP_USED are really set or cleared
  1439.                     in the true hardware table, the mask is considered
  1440.                     correctly.
  1441.  
  1442.                     Note that this function is the only method to clear
  1443.                     these two hardware flags, SetPropertiesA() or
  1444.                     RebuildTree() don't do this.
  1445.  
  1446.         mask    -    a bit mask of all bits to be changed.
  1447.  
  1448.         tags    -    A tag array with additional data. Check 
  1449.                     SetPropertiesA() for details.
  1450.  
  1451.     RESULTS
  1452.         A boolean success/failure indicator. Might fail if the context
  1453.         is protected or no memory is available for the modification or
  1454.         the page is not marked with MAPP_SINGLEPAGE.
  1455.  
  1456.     NOTES
  1457.         BE WARNED! This function is very restricted in its use. It may well
  1458.         return FALSE even if all parameters are valid due to hardware 
  1459.         restrictions. This function does never ever rebuild an MMU tree,
  1460.         it just modifies "what is there". If the library choose to optimize
  1461.         the MMU library tree and to map a couple of pages by one descriptor,
  1462.         for what reasons ever, this call will fail. The details when this
  1463.         happens depends not only on the MMU, but on the general system
  1464.         layout.
  1465.  
  1466.         The ONLY documented way to get a mapping for a page that can be
  1467.         adjusted using this call is to set the page to MAPP_SINGLEPAGE using
  1468.         SetPropertiesA() before.
  1469.  
  1470.         This call adjusts the hardware level of the MMU table if a descriptor 
  1471.         is available for a single page. It does not modify more than one
  1472.         page at once.
  1473.  
  1474.         It might happen that the library does not satisfy a request
  1475.         setting a page as "cacheable" if a DMA operation is currently in
  1476.         progress and the page must remain "nonacheable". However, the
  1477.         function will not fail in this case, but just delay the operation
  1478.         until the DMA is complete. The properties will always fall back to
  1479.         the next available option.
  1480.  
  1481.         This routine is safe to be called from within interrupts, it does
  1482.         not break any Forbid() or Disable() and is ideal for 
  1483.         quick-and-dirty repair operations within exceptions handlers,
  1484.         provided the MAPP_SINGLEPAGE flag has been set. 
  1485.  
  1486.     BUGS
  1487.         Note that MAPP_SINGLEPAGE is the flag you want here, not 
  1488.         MAPP_REPAIRABLE. That's something different!
  1489.  
  1490.         If the mask contains any property that requires user data, i.e.
  1491.         MAPP_REMAPPED or MAPP_SWAPPED, you *have* to redefine the user 
  1492.         data by tag items and MAY NOT leave them out, as the library 
  1493.         WILL NOT be able to restore the previously defined user data.
  1494.  
  1495.     SEE ALSO
  1496.             GetPagePropertiesA(), SetContextHook(), 
  1497.             GetPageSize(), RebuildTree(), SetPropertiesA(),
  1498.             SetMappingPropertiesA()
  1499. mmu.library/RebuildTree                            mmu.library/RebuildTree
  1500.  
  1501.     NAME    
  1502.         RebuildTree - build a MMU hardware tree from the software abstraction
  1503.         layer.
  1504.  
  1505.     SYNOPSIS
  1506.         result = RebuildTree( context );
  1507.         d0                      a0
  1508.  
  1509.         BOOL RebuildTree ( struct MMUContext * );
  1510.  
  1511.     FUNCTION
  1512.         This function adjusts the MMU hardware tree to reflect the settings
  1513.         of the software abstraction layer defined with SetPropertiesA().
  1514.  
  1515.     INPUTS
  1516.         context - a handle to the context to investigate or NULL for the
  1517.         active context.
  1518.  
  1519.     RESULTS
  1520.         a boolean success/failure indicator. TRUE if the operation was
  1521.         performed successfully.
  1522.  
  1523.     NOTES
  1524.         This is the big - and admittedly - slow one.
  1525.  
  1526.         Rebuilding the MMU tree is a relatively slow operation. The library
  1527.         tries to be smart about it and rebuilds only the pages whose
  1528.         mappings have been adjusted, but it's still a heavy beast.
  1529.  
  1530.         Properties temporarely defined with SetPagePropertiesA() will be
  1531.         lost after the rebuild, except for the MAPP_USED and MAPP_MODIFIED
  1532.         bits.
  1533.  
  1534.         In case of failure, the hardware layer will remain valid and un-
  1535.         changed, but the context remains marked as "dirty".
  1536.  
  1537.         BE WARNED! A consistent use of the two flags is only possible
  1538.         if the pages are marked as MAPP_SINGLE. The page building algorithm
  1539.         does not guarantee consistent use of these two bits except for
  1540.         MAPP_SINGLE pages. Even though it *might* look well most the time,
  1541.         it is not documented that these two bits are kept correctly for non-
  1542.         SINGLE pages. If you need MODIFIED or USED page information, the only 
  1543.         way to get them is to mark these pages as MAPP_SINGLE. There's no 
  1544.         consistent use for these flags if early termination descriptors 
  1545.         (hence, w/o MAPP_SINGLE) are used by the library. 
  1546.  
  1547.         Even though some pages in the abstraction layer might be marked as
  1548.         un-USED or un-MODIFIED, this routine NEVER clears the hardware bits.
  1549.         It requires a call to SetPagePropertiesA(), and hence the MAPP_SINGLE
  1550.         attribute (once again!) to do this.
  1551.  
  1552.     BUGS
  1553.         Much more should be said about this function.
  1554.  
  1555.     SEE ALSO
  1556.         SetPropertiesA(), SetPagePropertiesA(), GetPropertiesA(),
  1557.         GetPagePropertiesA(), RebuildTreesA()
  1558.  
  1559. mmu.library/RebuildTreesA                            mmu.library/RebuildTreesA
  1560.  
  1561.     NAME    
  1562.         RebuildTree - build a MMU hardware tree from the software abstraction
  1563.         layer for several contexts at once.                                (V41)
  1564.  
  1565.     SYNOPSIS
  1566.         result = RebuildTreesA( contextptrptr );
  1567.         d0                          a0
  1568.  
  1569.         result = RebuildTrees( context, context, ... );
  1570.  
  1571.  
  1572.         BOOL RebuildTreesA ( struct MMUContext ** );
  1573.  
  1574.         BOOL RebuildTrees ( struct MMUContext, ... ); 
  1575.  
  1576.     FUNCTION
  1577.         This function adjusts the MMU hardware tree to reflect the settings
  1578.         of the software abstraction layer defined with SetPropertiesA().
  1579.  
  1580.     INPUTS
  1581.         contextptr - a pointer to a NULL terminated array of context
  1582.         handles.
  1583.  
  1584.     RESULTS
  1585.         a boolean success/failure indicator. TRUE if the operation was
  1586.         performed successfully and all context could have been rebuild.
  1587.  
  1588.     NOTES
  1589.         This is the big - and admittedly - slow one.
  1590.  
  1591.         Rebuilding the MMU tree is a relatively slow operation. The library
  1592.         tries to be smart about it and rebuilds only the pages whose
  1593.         mappings have been adjusted, but it's still a heavy beast.
  1594.  
  1595.         Properties temporarely defined with SetPagePropertiesA() will be
  1596.         lost after the rebuild, except for the MAPP_USED and MAPP_MODIFIED
  1597.         bits.
  1598.  
  1599.         The advantage of this function is that it guarantees that all
  1600.         involved contexts remain unmodified and dirty in case one of the
  1601.         contexts cannot be rebuild. On success, it is guaranteed that all
  1602.         contexts will have been rebuild successfully.
  1603.  
  1604.         A special word has to be said about context locking here: This
  1605.         function will first call LockContextList(), and will then lock the
  1606.         individiual contexts in the order passed in. Hence, you've either
  1607.         to lock all contexts as well, and hence have to call 
  1608.         LockContextList() yourself as first step, or you must not lock any
  1609.         context of the contexts on the list. Everything else is dangerous
  1610.         and implies the risk of a deadlock.
  1611.  
  1612.         BE WARNED! A consistent use of the two flags is only possible
  1613.         if the pages are marked as MAPP_SINGLE. The page building algorithm
  1614.         does not guarantee consistent use of these two bits except for
  1615.         MAPP_SINGLE pages. Even though it *might* look well most the time,
  1616.         it is not documented that these two bits are kept correctly for non-
  1617.         SINGLE pages. If you need MODIFIED or USED page information, the only 
  1618.         way to get them is to mark these pages as MAPP_SINGLE. There's no 
  1619.         consistent use for these flags if early termination descriptors 
  1620.         (hence, w/o MAPP_SINGLE) are used by the library. 
  1621.  
  1622.         Even though some pages in the abstraction layer might be marked as
  1623.         un-USED or un-MODIFIED, this routine NEVER clears the hardware bits.
  1624.         It requires a call to SetPagePropertiesA(), and hence the MAPP_SINGLE
  1625.         attribute (once again!) to do this.
  1626.  
  1627.     BUGS
  1628.         Much more should be said about this function.
  1629.  
  1630.     SEE ALSO
  1631.         SetPropertiesA(), SetPagePropertiesA(), GetPropertiesA(),
  1632.         GetPagePropertiesA(), RebuildTree()
  1633.  
  1634. mmu.library/GetPropertiesA                        mmu.library/GetPropertiesA
  1635.  
  1636.     NAME
  1637.         GetPropertiesA - read memory attributes for a given logical page
  1638.         from the MMU table abstraction layer.
  1639.  
  1640.     SYNOPSIS
  1641.  
  1642.         flags = GetPropertiesA( context, lower, tags);
  1643.         d0                         a0         a1        a2
  1644.  
  1645.         ULONG GetPropertiesA( struct MMUContext *, void *, struct TagItem *);
  1646.  
  1647.  
  1648.         flags = GetProperties( context, lower, tag1, ...);
  1649.  
  1650.         ULONG GetProperties( struct MMUContext *, void *, Tag tag1, ...);
  1651.  
  1652.     FUNCTION
  1653.         This call reads the page properties of a certain address in
  1654.         memory from the software abstraction layer. It is the counterpart
  1655.         of SetPropertiesA().
  1656.  
  1657.     INPUTS
  1658.         context - a handle to the context to investigate or NULL for the
  1659.             active context.
  1660.  
  1661.         lower    - the logical address of the page to investigate. The
  1662.             size of the page depends on the hardware and is selected by
  1663.             the MMU library. The number of bytes in a page is returned
  1664.             by GetPageSize().
  1665.  
  1666.         tags    - additional tags. Currently defined are:
  1667.  
  1668.                 MAPTAG_DESTINATION    -    a pointer to a void * where 
  1669.                     the physical destination of the logical address is
  1670.                     filled in. Only available if the page is physically
  1671.                     mapped to somewhere. Not filled in otherwise.
  1672.  
  1673.                 MAPTAG_BLOCKID        -    read the a unique ID for the 
  1674.                     MAPP_SWAPPED property. Untouched if the page isn't
  1675.                     swapped. The tag data points to a long word which will
  1676.                     be filled in for swapped out pages.
  1677.                 
  1678.                 MAPTAG_USERDATA        -    read the unique cookie for 
  1679.                     INVALID pages, fill in the long word pointed to by
  1680.                     the tag data field.
  1681.  
  1682.                 MAPTAG_DESCRIPTOR    -    fill in the location of the
  1683.                     indirect descriptor which is used to perform the
  1684.                     mapping. Only used if MAPP_INDIRECT is used.
  1685.  
  1686.     RESULTS
  1687.         Returns a binary flags field for the attributes to define. See
  1688.         SetPropertiesA() for details. Remember that MAPP_USED or 
  1689.         MAPP_MODIFIED reflect the bits on the abstraction layer, not the
  1690.         true hardware bits. You MUST call GetPagePropertiesA() to read
  1691.         them, and hence *MUST* use MAPP_SINGLE pages.
  1692.  
  1693.     NOTES
  1694.         The page size can be read with GetPageSize(). Check the return    
  1695.         code of this call!
  1696.  
  1697.         The flags returned are valid for the given context, a different
  1698.         context may return a different flag setting and even a different
  1699.         physical locations.
  1700.  
  1701.         WARNING: The flags returned DO NOT reflect the hardware flags
  1702.         in the MMU table for the context. They DO reflect the settings
  1703.         installed with SetPropertiesA() on the abstraction layer of the
  1704.         MMU tables.
  1705.  
  1706.         The hardware table might differ for the following reasons:
  1707.  
  1708.             - SetPropertiesA() was called, but the changes haven't been
  1709.               made active with RebuildTree() yet.
  1710.             - A program modified the hardware layer directly using
  1711.               SetPagePropertiesA().
  1712.             - DMA is currently active and the page in question has 
  1713.               therefore been marked as non-cacheable temporarely.
  1714.  
  1715.         Additionally, the library might have adjusted the abstraction
  1716.         layer itself by allocating non-cacheabe memory for its
  1717.         MMU tables.
  1718.  
  1719.         This routine is *NOT* safe to be called from within interrupts.
  1720.  
  1721.     BUGS
  1722.  
  1723.     SEE ALSO
  1724.         SetPropertiesA(), SetContextHook(), GetMappingPropertiesA(),
  1725.         GetPageSize(), GetPagePropertiesA(), RebuildTree()
  1726.  
  1727. mmu.library/GetPagePropertiesA                    mmu.library/GetPagePropertiesA
  1728.  
  1729.     
  1730.     NAME
  1731.         GetPropertiesA - read memory attributes from the hardware level
  1732.         for a given logical page. 
  1733.  
  1734.     SYNOPSIS
  1735.  
  1736.         flags = GetPagePropertiesA( context, lower, tags);
  1737.         d0                              a0          a1     a2
  1738.  
  1739.         ULONG GetPagePropertiesA( struct MMUContext *, void *, 
  1740.  
  1741.                                 struct TagItem *);
  1742.  
  1743.  
  1744.         result = GetPageProperties( context, lower, tag1, ...);
  1745.  
  1746.         BOOL GetPageProperties( struct MMUContext *, void *, Tag tag1, ...);
  1747.  
  1748.     FUNCTION
  1749.         This call reads the page properties of a certain address in
  1750.         memory directly from the hardware. It is the counterpart
  1751.         of SetPagePropertiesA().
  1752.  
  1753.     INPUTS
  1754.         context - a handle to the context to investigate or NULL for the
  1755.             active context. The library might use the MMU hardware directly
  1756.             if NULL is passed in, this call might be faster therefore.
  1757.  
  1758.         lower    - the logical address of the page to investigate. The
  1759.             size of the page depends on the hardware and is selected by
  1760.             the MMU library. The number of bytes in a page is returned
  1761.             by GetPageSize().
  1762.  
  1763.         tags    - additional tags. See GetPropertiesA() for details.
  1764.  
  1765.  
  1766.     RESULTS
  1767.         Returns a binary flags field for the attributes to define. See
  1768.         SetPropertiesA() for details.
  1769.  
  1770.     NOTES
  1771.         The page size can be read with GetPageSize(). 
  1772.  
  1773.         The flags returned are valid for the given context, a different
  1774.         context may return a different flag setting and even a different
  1775.         physical location.
  1776.  
  1777.         WARNING: The flags returned reflect the NOT the hardware flags
  1778.         in the MMU table for the context except for the MODIFIED and USED
  1779.         properties, even though the hardware level is *almost* consistent
  1780.         with these flags. 
  1781.  
  1782.         The hardware table might differ slightly in the following 
  1783.         situations:
  1784.  
  1785.             - DMA is currently active and the page in question has 
  1786.               therefore been marked as non-cacheable temporarely.
  1787.               Therefore, the cache settings returned are what will be
  1788.               re-installed here when DMA is finished. The library
  1789.               will "fake" the flags you have installed for the page
  1790.               investigated.
  1791.             - The library will use invalid descriptors to implement
  1792.               supervisor only or swapped pages.
  1793.  
  1794.         However, even though the flags might differ from the hardware
  1795.         flags, you're always safe to re-install the properties with
  1796.         SetPageProperties, there's no need to keep track of pecularities
  1797.         like cache disabling for DMA pages. The library does this for you.
  1798.  
  1799.         MAPP_MODIFIED and MAPP_USED are always read from the hardware
  1800.         directly.
  1801.  
  1802.         KEEP IN MIND that these two bits are only set and handled
  1803.         consistently for MAPP_SINGLE pages. You MUST NOT interpret
  1804.         them in all other cases, their values might get lost on a
  1805.         RebuildTree() call.
  1806.  
  1807.         This routine is safe to be called from within interrupts, most
  1808.         useful within exception handlers.
  1809.  
  1810.     BUGS
  1811.  
  1812.     SEE ALSO
  1813.             GetPropertiesA(), SetContextHook(), 
  1814.             GetPageSize(), SetPagePropertiesA(), RebuildTree()
  1815.  
  1816. mmu.library/AllocAligned                                mmu.library/AllocAligned
  1817.  
  1818.     NAME
  1819.         AllocAligned     -    allocate memory aligned to a memory border.
  1820.  
  1821.     SYNOPSIS
  1822.         mem = AllocAligned( bytesize, reqments, align );
  1823.         d0                    d0           d1         a0
  1824.  
  1825.         void * AllocAligned( ULONG, ULONG, ULONG);
  1826.  
  1827.     FUNCTION
  1828.         Allocate memory aligned to certain boundaries.
  1829.  
  1830.     INPUTS
  1831.         bytesize - the size of the memory to allocate. 
  1832.  
  1833.         reqments -    exec style memory attributes
  1834.  
  1835.         align    -    the alignment restrictions of the page.
  1836.                     MUST be a power of two.
  1837.  
  1838.     RETURNS
  1839.         a pointer to the allocated memory, aligned to the given border or
  1840.         NULL if no free physical memory could be found.
  1841.  
  1842.     NOTES
  1843.         Examples of how to use the "align" parameter:
  1844.  
  1845.         mem = AllocAligned(123,MEMF_PUBLIC|MEMF_CLEAR,1024);
  1846.  
  1847.         will allocate 123 bytes starting at a 1024 byte border, i.e. 
  1848.         the address returned will be divisible by 1024. The call will 
  1849.         clear the 123 bytes, NOT MORE.
  1850.  
  1851.         This is a service routine for the memory.library and shouldn't be
  1852.         used for all-day purposes.
  1853.  
  1854.         A DOS process will have its pr_Result2 field set to
  1855.         ERROR_NO_FREE_STORE if the memory allocation fails.
  1856.  
  1857.         The mmu.library calls this function by using its LVO library entry,
  1858.         so it can be patched to a smarter implementation if desired.
  1859.  
  1860.     BUGS
  1861.  
  1862.     SEE ALSO
  1863.         GetPageSize(), exec/memory.h
  1864.  
  1865. mmu.library/LockMMUContext                        mmu.library/LockMMUContext
  1866.  
  1867.     NAME
  1868.         LockMMUContext        -    lock a MMU context
  1869.  
  1870.     SYNOPSIS
  1871.         LockMMUContext( context );
  1872.                           a0
  1873.  
  1874.         void LockMMUContext( struct MMUContext * );
  1875.  
  1876.     FUNCTION
  1877.         Lock the software abstraction layer of the MMU table against
  1878.         modifications from other tasks.
  1879.  
  1880.     INPUTS
  1881.         A handle to a MMUContext or NULL for the active context.
  1882.  
  1883.     RETURNS
  1884.  
  1885.     NOTES
  1886.          This mechanism DOES NOT avoid changes of the MMU table on a lower
  1887.         level by SetPageProperties(), only SetProperties() from other
  1888.         tasks will be locked.
  1889.         Hence, it locks the abstraction layer, but not the hardware
  1890.         level.
  1891.  
  1892.         DO NOT lock more than one context at once, unless you locked
  1893.         also the context list with LockContextList(). Not following 
  1894.         this rule might cause deadlocks.
  1895.  
  1896.     BUGS
  1897.  
  1898.     SEE ALSO
  1899.         UnlockMMUContext(), SetPageProperties(), SetProperties(),
  1900.         LockContextList().
  1901.  
  1902. mmu.library/UnlockMMUContext                    mmu.library/UnlockMMUContext
  1903.  
  1904.     NAME
  1905.         UnlockMMUContext    -    release a MMU context
  1906.  
  1907.     SYNOPSIS
  1908.         UnlockMMUContext( context );
  1909.                           a0
  1910.  
  1911.         void UnlockMMUContext( struct MMUContext * );
  1912.  
  1913.     FUNCTION
  1914.         Release the software abstraction layer of the MMU table, allow
  1915.         modifications from other tasks.
  1916.  
  1917.     INPUTS
  1918.         A handle to a MMUContext or NULL for the active context.
  1919.  
  1920.     RETURNS
  1921.  
  1922.     NOTES
  1923.          This mechanism DOES NOT avoid changes of the MMU table on a lower
  1924.         level by SetPageProperties(), only SetProperties() from other
  1925.         tasks will be locked.
  1926.         Hence, it locks the abstraction layer, but not the hardware
  1927.         level.
  1928.  
  1929.     BUGS
  1930.  
  1931.     SEE ALSO
  1932.         LockMMUContext(), SetPageProperties(), SetProperties(),
  1933.         AttemptLockMMUContext()
  1934.  
  1935. mmu.library/AttemptLockMMUContext            mmu.library/AttemptLockMMUContext
  1936.  
  1937.     NAME
  1938.         AttemptLockMMUContext        -    attempt to lock a MMU context
  1939.  
  1940.     SYNOPSIS
  1941.         ok = AttemptLockMMUContext( context );
  1942.                                         a0
  1943.  
  1944.         struct MMUContext * AttemptLockMMUContext( struct MMUContext * );
  1945.  
  1946.     FUNCTION
  1947.         Grants non-blocking access to a MMU context.
  1948.         Attempts to lock the software abstraction layer of the MMU 
  1949.         table against modifications from other tasks. 
  1950.  
  1951.     INPUTS
  1952.         A handle to a MMUContext or NULL for the active context.
  1953.  
  1954.     RETURNS
  1955.         TRUE in case of success - the context is then locked for you
  1956.         and this lock must be released with UnlockMMUContext().
  1957.         FALSE in case any other task holds a lock.
  1958.  
  1959.     NOTES
  1960.          This mechanism DOES NOT avoid changes of the MMU table on a lower
  1961.         level by SetPageProperties(), only SetProperties() from other
  1962.         tasks will be locked.
  1963.         Hence, it locks the abstraction layer, but not the hardware
  1964.         level.
  1965.  
  1966.         DO NOT lock more than one context at once, unless you locked
  1967.         also the context list with LockContextList(). Not following 
  1968.         this rule might cause deadlocks.
  1969.  
  1970.     BUGS
  1971.         In pre-V39 machines, this call does not lock the context again
  1972.         in case you already hold a lock. This is a bug of the pre-V39
  1973.         AttemptSemaphore(), read the exec autodocs for a workaround.
  1974.  
  1975.     SEE ALSO
  1976.         UnlockMMUContext(), SetPageProperties(), SetProperties(),
  1977.         LockContextList(), AttemptSemaphore()
  1978.  
  1979. mmu.library/LockContextList                        mmu.library/LockContextList
  1980.  
  1981.     NAME
  1982.         LockContextList        -    arbitrate a master lock.
  1983.  
  1984.     SYNOPSIS
  1985.         LockContextList( );
  1986.  
  1987.         void LockContextList( void );
  1988.  
  1989.     FUNCTION
  1990.         Arbitrates a master lock that allows locking more than one context
  1991.         at once to avoid deadlocks.
  1992.  
  1993.     INPUTS
  1994.  
  1995.     RETURNS
  1996.  
  1997.     NOTES
  1998.         This lock grants access for locking more than one context at once,
  1999.         to avoid deadlocks. I.e. in case you need to lock more than one
  2000.         context at a time, get this lock FIRST, then lock the contexts
  2001.         in any order you prefer.
  2002.  
  2003.         This call DOES NOT avoid modification of the context list or 
  2004.         individual contexts at all, i.e. other tasks are still able
  2005.         to create and to dispose contexts. To avoid this, you must lock
  2006.         the contexts afterwards.
  2007.  
  2008.         When you're done with the contexts, unlock the contexts first,
  2009.         THEN release this lock with UnlockContextList(). NOTE THE ORDER!
  2010.     
  2011.     BUGS
  2012.  
  2013.     SEE ALSO
  2014.         UnlockMMUContextList(), LockMMUContext(), AttemptLockContextList()
  2015.  
  2016. mmu.library/UnlockContextList                mmu.library/UnlockContextList
  2017.  
  2018.     NAME
  2019.         UnlockContextList    -    release the master context lock
  2020.  
  2021.     SYNOPSIS
  2022.         UnlockContextList( );
  2023.  
  2024.         void UnlockContextList( void );
  2025.  
  2026.     FUNCTION
  2027.         Releases the master lock that allows locking more than one context
  2028.         at once to avoid deadlocks.
  2029.  
  2030.     INPUTS
  2031.  
  2032.     RETURNS
  2033.  
  2034.     NOTES
  2035.         This lock grants access for locking more than one context at once,
  2036.         to avoid deadlocks. I.e. in case you need to lock more than one
  2037.         context at a time, get this lock FIRST, then lock the contexts
  2038.         in any order you prefer.
  2039.  
  2040.         This call DOES NOT avoid modification of the context list or 
  2041.         individual contexts at all, i.e. other tasks are still able
  2042.         to create and to dispose contexts. To avoid this, you must lock
  2043.         the contexts afterwards.
  2044.  
  2045.         When you're done with the contexts, unlock the contexts first,
  2046.         THEN release this lock with UnlockContextList(). NOTE THE ORDER!
  2047.  
  2048.     BUGS
  2049.  
  2050.     SEE ALSO
  2051.         LockContextList(), LockMMUContext(), AttemptLockContextList()
  2052.  
  2053. mmu.library/AttemptLockContextList            mmu.library/AttemptLockContextList
  2054.  
  2055.     NAME
  2056.         AttemptLockContextList        -    attempt to arbitrate the master lock.
  2057.  
  2058.     SYNOPSIS
  2059.         ok = AttemptLockContextList( );
  2060.  
  2061.         LONG AttemptLockContextList( void );
  2062.  
  2063.     FUNCTION
  2064.         Attempts granting the context master lock in a non-blocking
  2065.         fashion. 
  2066.  
  2067.     INPUTS
  2068.  
  2069.     RETURNS
  2070.         TRUE in case the master lock could be arbitrated. You have then to
  2071.         release it with UnlockContextList().
  2072.         FALSE in case it is already locked and access could not be granted.
  2073.  
  2074.     NOTES
  2075.         This lock grants access for locking more than one context at once,
  2076.         to avoid deadlocks. I.e. in case you need to lock more than one
  2077.         context at a time, get this lock FIRST, then lock the contexts
  2078.         in any order you prefer.
  2079.  
  2080.         This call DOES NOT avoid modification of the context list or 
  2081.         individual contexts at all, i.e. other tasks are still able
  2082.         to create and to dispose contexts. To avoid this, you must lock
  2083.         the contexts afterwards.
  2084.  
  2085.         When you're done with the contexts, unlock the contexts first,
  2086.         THEN release this lock with UnlockContextList(). NOTE THE ORDER!
  2087.  
  2088.     BUGS
  2089.         In pre-V39 machines, this call does not lock the context again
  2090.         in case you already hold a lock. This is a bug of the pre-V39
  2091.         AttemptSemaphore(), read the exec autodocs for a workaround.
  2092.  
  2093.     SEE ALSO
  2094.         UnlockContextList(), LockMMUContext(), LockContextList(),
  2095.         AttemptLockSemaphore()
  2096.     
  2097. mmu.library/AllocLineVec                            mmu.library/AllocLineVec
  2098.  
  2099.     NAME
  2100.         AllocLineMem        -     allocate cache line aligned, keep size
  2101.  
  2102.     SYNOPSIS
  2103.         AllocLineVec ( bytesize , attributes );
  2104.                           d0        d1
  2105.  
  2106.         void * AllocLineVec ( ULONG, ULONG );
  2107.  
  2108.     FUNCTION
  2109.         Allocates memory like AllocVec(), but the memory is guaranteed
  2110.         to be aligned to cache lines of the processors in the system,
  2111.         even though the pointer returned IS NOT.
  2112.         Minimal guaranteed alignment is currently 32 bytes, i.e. a 
  2113.         PPC cache line. Future hardware may require stricter alignments.
  2114.  
  2115.         AllocLineMem'd memory is released with FreeVec() from the
  2116.         exec.library.
  2117.  
  2118.     INPUTS
  2119.         bytesize     -    the size of the memory block in bytes.
  2120.         attributes    -    memory attributes, see exec.library/AllocMem.
  2121.  
  2122.     RETURNS
  2123.         a pointer to the memory allocated or NULL on failure.
  2124.  
  2125.         A DOS process will have its pr_Result2 field set to
  2126.         ERROR_NO_FREE_STORE if the memory allocation fails.
  2127.  
  2128.     NOTES
  2129.         BIG WARNING: The pointer returned IS NEVER cache line aligned
  2130.         itself, but the complete memory block toghether with the
  2131.         vector size is kept in a cache line, regardless of the size
  2132.         passed in. Due to alignment restrictions, the routine might
  2133.         allocate a larger memory block than requested. It is however
  2134.         guaranteed that AT LEAST the size requested is returned, and
  2135.         that a FreeVec() will, indeed, free all memory.
  2136.  
  2137.         If MEMF_CLEAR is requested, the memory is cleared on the
  2138.         MC68K side, but the "zeros written" might be still in the
  2139.         cache. Hence, it is a good idea to flush the cache if the
  2140.         memory is passed over to the PPC.
  2141.  
  2142.         However, the vector size itself is always "pushed" to 
  2143.         memory, it is therefore guaranteed to be properly written
  2144.         back to the memory.
  2145.  
  2146.         The memory allocated this way is released by FreeVec() of
  2147.         the exec.library.
  2148.  
  2149.     BUGS
  2150.  
  2151.     SEE ALSO
  2152.         exec.library/AllocVec(), exec.library/FreeVec(), AllocLineMem()
  2153.  
  2154. mmu.library/PhysicalPageLocation            mmu.library/PhysicalPageLocation
  2155.  
  2156.     NAME
  2157.         PhysicalPageLocation    -    translate logical address to physical
  2158.  
  2159.     SYNOPSIS
  2160.         addr = PhysicalPageLocation( context , addr );
  2161.         d0                               a0         a1
  2162.  
  2163.         void * PhysicalPageLocation( struct MMUContext * , void * );
  2164.  
  2165.     FUNCTION
  2166.         This function finds the physical address for the logical address
  2167.         passed in by scanning the MMU hardware table. 
  2168.         If the physical address is not available, NULL is returned.
  2169.  
  2170.     INPUTS
  2171.         context - the context to enter or NULL for the current context.
  2172.         addr    - the logical address to be translated.
  2173.  
  2174.     RETURNS
  2175.         the physical address of the logical address passed in, or NULL
  2176.         in case the logical address is not swapped in or otherwise out of
  2177.         control of the library.
  2178.  
  2179.     NOTES
  2180.         This is the low-level function, consider using the high-level
  2181.         function PhysicalLocation() when possible.
  2182.         This call can be safely used within interrupts.
  2183.  
  2184.     BUGS
  2185.         The function will also return NULL in case the logical address
  2186.         is translated to the address 0L. However, 0L should never be 
  2187.         used as physical address anyhow.
  2188.  
  2189.     SEE ALSO
  2190.         GetPageProperties(), PhysicalLocation()
  2191. mmu.library/PhysicalLocation                    mmu.library/PhysicalLocation
  2192.  
  2193.     NAME
  2194.         PhysicalLocation    -    translate logical address to physical
  2195.  
  2196.     SYNOPSIS
  2197.         props = PhysicalLocation( context, addrptr, lenptr );
  2198.         d0                               d1         a0          a1
  2199.  
  2200.         ULONG PhysicalLocation( struct MMUContext * , void ** , ULONG * );
  2201.  
  2202.     FUNCTION
  2203.         This function finds the physical address for the logical address
  2204.         passed in by scanning the software abstraction layer.
  2205.         If the physical address is not available, NULL is returned.
  2206.  
  2207.     INPUTS
  2208.         context - the context to enter or NULL for the current context.
  2209.         addrptr - points to the logical address to be translated.
  2210.                   The physical address is filled in here.
  2211.         lenptr     - Points to the length of the address range to be trans-
  2212.                   lated. The function returns the length of the largest 
  2213.                   possible continous memory range contained in the memory
  2214.                   range passed in. Hence, this function may shorten the
  2215.                   memory block for fragmentized memory models.
  2216.  
  2217.     RETURNS
  2218.         the properties of the memory range.
  2219.  
  2220.     NOTES
  2221.         This is the high-level function, it is not callable from within
  2222.         interrupts.
  2223.  
  2224.         In case you've to operate on a range of physical memory, start
  2225.         the translation with this call, then compare the size returned
  2226.         with the size of the memory block passed in. Because this 
  2227.         function may shorten the memory size in case the physical 
  2228.         memory is fragmentated, you should be prepared that the size
  2229.         returned is smaller than what was passed in. In this case, operate
  2230.         on the memory region returned, then add the returned size to
  2231.         the original logical address and call this function again to
  2232.         get the physical location of the next chunk.
  2233.  
  2234.     BUGS
  2235.         The function will also return NULL in case the logical address
  2236.         is translated to the address 0L. However, 0L should never be 
  2237.         used as physical address anyhow.
  2238.  
  2239.     SEE ALSO
  2240.         GetProperties(), PhysicalPageLocation()
  2241. mmu.library/DMAInitiate                                mmu.library/DMAInitiate
  2242.  
  2243.     NAME
  2244.         DMAInitiate        -    start a DMA transport given a logical address.
  2245.  
  2246.     SYNOPSIS
  2247.         DMAInitiate( context, addrptr, lenptr, write );
  2248.                         d1         a0          a1    d0
  2249.  
  2250.         void DMAInitiate( struct MMUContext * , void ** , ULONG * , BOOL );
  2251.  
  2252.     FUNCTION
  2253.         This function finds the physical address for the logical address
  2254.         passed in by scanning a backup of the MMU translation tree.
  2255.         It ignores modifications made by the high-level and low-level
  2256.         functions unless RebuildTree() is called.
  2257.  
  2258.     INPUTS
  2259.         context - the context to enter or NULL for the current context.
  2260.                   NOTE: This parameter is currently a dummy and should be
  2261.                   set to NULL. The mmu.library will always use the public
  2262.                   context for translation.
  2263.         addrptr - points to the logical address to be translated.
  2264.                   The physical address is filled in here.
  2265.         lenptr     - Points to the length of the address range to be trans-
  2266.                   lated. The function returns the length of the largest 
  2267.                   possible continous memory range contained in the memory
  2268.                   range passed in. Hence, this function may shorten the
  2269.                   memory block for fragmentized memory models.
  2270.         write    - set this to TRUE for transports from a DMA device INTO
  2271.                   the memory, i.e. device reads. Set this to FALSE for
  2272.                   writes from memory to the device.
  2273.  
  2274.     RETURNS
  2275.  
  2276.     NOTES
  2277.         The function checks whether the memory range passed in is available
  2278.         for DMA. It will guru in case it is not, i.e. the page is either
  2279.         swapped out, invalid, indirect, or write protected for
  2280.         DMA device reads. Reads into ROM addresses are silently tolerated,
  2281.         and, hence, are translations to and from blank dummy pages.
  2282.  
  2283.         This function is callable from within interrupts, but does only
  2284.         use a backup of the high-level table for its translation.
  2285.         Changes to the software abstraction level are not visible for
  2286.         this function unless RebuildTree() is called. Changes to the
  2287.         hardware level are not at all visible to this (and all other
  2288.         high-level) functions.
  2289.  
  2290.         In case you've to operate on a range of physical memory, start
  2291.         the translation with this call, then compare the size returned
  2292.         with the size of the memory block passed in. Because this 
  2293.         function may shorten the memory size in case the physical 
  2294.         memory is fragmentated, you should be prepared that the size
  2295.         returned is smaller than what was passed in. With the physical
  2296.         address returned, start the DMA and call DMATerminate() when
  2297.         done.
  2298.         In case the returned size is smaller than the block passed in,
  2299.         add the returned size to the original logical address and 
  2300.         call this function again to get the physical location of the 
  2301.         next chunk.
  2302.  
  2303.         EACH CALL TO DMAInitiate() must be matched by ONE AND PRECISELY
  2304.         ONE call to DMATerminate().
  2305.  
  2306.         Even though this function does not require locking the context,    
  2307.         I highly recommend doing so. It won't crash if you don't, but
  2308.         someone else could modify the MMU translation table in between.
  2309.         The library can deal with that, but the result of the DMA 
  2310.         operation might be different than what you expect.
  2311.  
  2312.     BUGS
  2313.         This function should really use the context passed in, but
  2314.         since most (if not all) DMA device drivers do not keep the 
  2315.         context of the task that actually initiated the transfer and
  2316.         hence would use the wrong context anyhow, DMA is currently limited
  2317.         to the public context.
  2318.  
  2319.     SEE ALSO
  2320.         DMATerminate(), PhysicalPageLocation(), exec/CachePreDMA()
  2321. mmu.library/DMATerminate                            mmu.library/DMATerminate
  2322.  
  2323.     NAME
  2324.         DMATerminate    -    end a DMA transfer initiated by DMAInitiate.
  2325.  
  2326.     SYNOPSIS
  2327.         DMATerminate( context );
  2328.                         d1         
  2329.  
  2330.         void DMATerminate( struct MMUContext * );
  2331.  
  2332.     FUNCTION
  2333.         This function ends a DMA transfer initiated by DMAInitate. It
  2334.         releases the resources by the first call.
  2335.  
  2336.     INPUTS
  2337.         context - the context to enter or NULL for the current context.
  2338.                   NOTE: This parameter is currently a dummy and should be
  2339.                   set to NULL. The mmu.library will always use the public
  2340.                   context for translation.
  2341.  
  2342.     RETURNS
  2343.  
  2344.     NOTES
  2345.         This function is callable from within interrupts, but does only
  2346.         use a backup of the high-level table for its translation.
  2347.         Changes to the software abstraction level are not visible for
  2348.         this function unless RebuildTree() is called. Changes to the
  2349.         hardware level are not at all visible to this (and all other
  2350.         high-level) functions.
  2351.  
  2352.         EACH CALL TO DMAInitiate() must be matched by ONE AND PRECISELY
  2353.         ONE call to DMATerminate().
  2354.  
  2355.         For details, check the DMAInitiate() function.
  2356.  
  2357.     BUGS
  2358.         This function should really use the context passed in, but
  2359.         since most (if not all) DMA device drivers do not keep the 
  2360.         context of the task that actually initiated the transfer and
  2361.         hence would use the wrong context anyhow, DMA is currently limited
  2362.         to the public context.
  2363.  
  2364.     SEE ALSO
  2365.         DMAInitiate(), PhysicalPageLocation(), exec/CachePostDMA()
  2366. mmu.library/GetMapping                                mmu.library/GetMapping
  2367.  
  2368.     NAME
  2369.         GetMapping     -    get access to the memory map of a MMUContext
  2370.  
  2371.     SYNOPSIS
  2372.         list = GetMapping( context );
  2373.         d0                    a0
  2374.  
  2375.         struct MinList * GetMapping( struct MMUContext * );
  2376.  
  2377.     FUNCTION
  2378.         This function makes a copy of the MapNodes for the given context.
  2379.         The nodes in this list describe the memory map as seen from tasks
  2380.         attached to this context, sorted by logical addresses.
  2381.         The list must be released afterwards with ReleaseMapping().
  2382.  
  2383.     INPUTS
  2384.         context - the context to enter or NULL for the current context.
  2385.  
  2386.     RETURNS
  2387.         a pointer to a struct MinList which contains the MapNodes for this
  2388.         context, sorted by physical address, or NULL in case of failure.
  2389.  
  2390.     NOTES
  2391.         The nodes are just a copy of the real nodes within the context.
  2392.     
  2393.         This function is most useful to make a backup of the context
  2394.         memory map before altering it. In case any of the modifications
  2395.         fail, you are able to undo all modifications completely with
  2396.         a call to SetPropertyList() - which can't fail. 
  2397.  
  2398.         To give an example:
  2399.  
  2400.         /* make a backup of the context how it looks now */
  2401.  
  2402.         LockMMUContext(ctx);
  2403.  
  2404.         if (list=GetMapping(ctx)) {
  2405.             fine=TRUE;
  2406.  
  2407.             /* Try to alter it, step by step. */
  2408.  
  2409.             if (!SetProperties(...)) 
  2410.                 fine=FALSE;
  2411.  
  2412.             if (!SetProperties(...))
  2413.                 fine=FALSE;
  2414.  
  2415.             /* etc, etc.... */
  2416.  
  2417.             /* Oops, we failed! Re-install the old setup. */
  2418.             if (!fine) 
  2419.                 SetPropertyList(ctx,list);
  2420.         }
  2421.         
  2422.         ReleaseMapping(ctx,list);
  2423.         UnlockMMUContext(ctx);
  2424.         /* and so on... */
  2425.  
  2426.         Note that you've still to call ReleaseContextList(), even in
  2427.         case of failure when you've already re-installed backup property
  2428.         list.
  2429.  
  2430.     BUGS
  2431.  
  2432.     SEE ALSO
  2433.         ReleaseMapping(), SetPropertyList(), mmu/context.h
  2434. mmu.library/ReleaseMapping                            mmu.library/ReleaseMapping
  2435.  
  2436.     NAME
  2437.         ReleaseMapping     -    get access to the memory map
  2438.  
  2439.     SYNOPSIS
  2440.         ReleaseMapping( context , list );
  2441.                          a0           a1
  2442.  
  2443.         void ReleaseMapping( struct MMUContext * , struct MinList * );
  2444.  
  2445.     FUNCTION
  2446.         This function releases the list of MapNodes arbitrated by 
  2447.         GetMapping.
  2448.  
  2449.     INPUTS
  2450.         context - the context the nodes where taken from.
  2451.         list    - the backup property list to release.
  2452.  
  2453.     RETURNS
  2454.  
  2455.     NOTES
  2456.         This function *MUST* be called, even in case the property list
  2457.         was re-installed with SetPropertyList().
  2458.  
  2459.     BUGS
  2460.  
  2461.     SEE ALSO
  2462.         NewMapping(), GetMapping(), SetPropertyList()
  2463.  
  2464. mmu.library/NewMapping                                mmu.library/NewMapping
  2465.  
  2466.     NAME
  2467.         NewMapping            -    build a new memory map
  2468.  
  2469.     SYNOPSIS
  2470.         list = NewMapping ( );
  2471.         d0
  2472.  
  2473.         struct MinList * NewMapping ( void );
  2474.  
  2475.     FUNCTION
  2476.         Build and initialize a new memory map list. All addresses in this
  2477.         list will be marked as MAPP_BLANK.
  2478.  
  2479.     INPUTS
  2480.         nothing.
  2481.  
  2482.     RESULTS
  2483.         a MinList structure, initialized with MapNodes representing a
  2484.         completely blank memory layout or NULL on failure. You either need 
  2485.         to copy the layout from a context with CopyContextRegion(), or 
  2486.         define your own layout with calls to SetMappingPropertiesA().
  2487.  
  2488.     NOTES
  2489.         Don't forget to release the list (and its contents) with 
  2490.         ReleaseMapping() when you're done.
  2491.  
  2492.     BUGS
  2493.  
  2494.     SEE ALSO
  2495.         CopyContextRegion(), SetMappingPropertiesA(), ReleaseMapping(),
  2496.         GetMapping()
  2497.  
  2498. mmu.library/CopyMapping                                mmu.library/CopyMapping
  2499.  
  2500.     NAME
  2501.         CopyMapping            -    transfer memory properties between lists
  2502.  
  2503.     SYNOPSIS
  2504.         fine = CopyMapping ( from , to , base , length , mask );
  2505.         d0                     a0        a1     d0        d1         d2        
  2506.  
  2507.  
  2508.         BOOL CopyMapping ( struct MinList * , struct MinList * ,
  2509.  
  2510.                              ULONG , ULONG , ULONG );
  2511.  
  2512.     FUNCTION
  2513.         Copy the memory properties from one memory map to another, thru
  2514.         a mask.
  2515.  
  2516.     INPUTS
  2517.         from    -    the memory map which is (partially) to be transfered.
  2518.         to        -    the destination of the copy operation.
  2519.         base    -    base address. Memory properties will be copied starting
  2520.                     at this address.
  2521.         length    -    length of the memory region in bytes whose properties
  2522.                     shall be transfered.
  2523.         mask    -    a mask of property bits which are to be transfered. A
  2524.                     zero bit in this mask indicates that the corresponding
  2525.                     property in the destination will not be touched. For
  2526.                     all the properties, check the SetPropertiesA() function.
  2527.  
  2528.     RESULTS
  2529.         a boolean success/failure indicator. It is TRUE in case the 
  2530.         operation was performed, FALSE otherwise. The destination will
  2531.         not have been touched at all in this case.
  2532.  
  2533.     NOTES
  2534.         this call does not copy memory. It just copies memory attributes
  2535.         from one memory map to another.
  2536.  
  2537.         Check CopyContextRegion() to copy the properties from a context
  2538.         instead from a list.
  2539.  
  2540.         Since this call is not context based, the library will not be able
  2541.         to perform checks for correct page alignment, you have to do that
  2542.         yourself. Especially, note that SetPropertyList() - which attaches
  2543.         a memory map to a context - does not perform any check on this
  2544.         list either. Hence, *NOT* checking for page alignment here might
  2545.         result in an invalid context if you try to attach an incorrectly
  2546.         aligned list to a context later on. 
  2547.  
  2548.     BUGS
  2549.  
  2550.     SEE ALSO
  2551.         SetPropertyList(), ReleaseMapping(), DupMapping(), SetPropertiesA(),
  2552.         CopyContextRegion()
  2553.  
  2554. mmu.library/DupMapping                                mmu.library/DupMapping
  2555.  
  2556.     NAME
  2557.         DupMapping            -    make a one-to-one copy of a memory map
  2558.  
  2559.     SYNOPSIS
  2560.         dup = DupMapping ( list );
  2561.         d0                    a0
  2562.  
  2563.         struct MinList * DupMapping( struct MinList * );
  2564.  
  2565.     FUNCTION
  2566.         this call builds an identical copy of the memory map passed in.
  2567.  
  2568.     INPUTS
  2569.         list    -    the memory map to be copied.
  2570.  
  2571.     RESULTS
  2572.         another memory list, identical to the list passed in, or NULL on
  2573.         failure.
  2574.  
  2575.     NOTES
  2576.         Don't forget to release the memory list with ReleaseMapping()
  2577.         if you're done with it. You need to release both, the original as
  2578.         well as the duplicate.
  2579.         In case you want to make a copy of the memory map of a context,
  2580.         use GetMapping() instead.
  2581.  
  2582.     BUGS
  2583.  
  2584.     SEE ALSO
  2585.         GetMapping(), ReleaseMapping()
  2586.  
  2587. mmu.library/CopyContextRegion                    mmu.library/CopyContextRegion
  2588.  
  2589.     NAME
  2590.         CopyContextRegion    -    transfer properties from a context to a list
  2591.  
  2592.     SYNOPSIS
  2593.         fine = CopyContextRegion ( ctx, list, base, length, mask );
  2594.         d0                            a0   a1       d0     d1         d2
  2595.  
  2596.         BOOL CopyContextRegion ( struct MMUContext *, struct MinList *,
  2597.                                  
  2598.                                  ULONG, ULONG, ULONG );
  2599.  
  2600.     FUNCTION
  2601.         Copy the properties of a memory region defined by a context to 
  2602.         another memory map, thru a mask.
  2603.  
  2604.     INPUTS
  2605.         ctx        -    source context whose memory map shall be transfered.
  2606.         list    -    the destination memory map which is to be altered.
  2607.         base    -    base address of the memory region whose properties are
  2608.                     to be copied.
  2609.         length    -    length of the memory region in bytes whose properties
  2610.                     will be transfered.
  2611.         mask    -    a mask of property bits, see the SetPropertiesA() 
  2612.                     function for a detailed explanation. A zero bit in this
  2613.                     mask means that the corresponding property in the 
  2614.                     destination will be left alone and will remain unchanged.
  2615.  
  2616.     RESULTS
  2617.         a boolean success/failure indicator, TRUE for success. On failure,
  2618.         the destination memory map will not have been touched at all.
  2619.  
  2620.     NOTES
  2621.         This call does not copy memory at all, it just defines the memory
  2622.         properties of a given memory map from that of a given context.
  2623.  
  2624.         Check CopyMapping() to transport memory properties from one list
  2625.         to another.
  2626.  
  2627.         Since this call is not context based, the library will not be able
  2628.         to perform checks for correct page alignment, you have to do that
  2629.         yourself. Especially, note that SetPropertyList() - which attaches
  2630.         a memory map to a context - does not perform any check on this
  2631.         list either. Hence, *NOT* checking for page alignment here might
  2632.         result in an invalid context if you try to attach an incorrectly
  2633.         aligned list to a context later on. 
  2634.  
  2635.     BUGS
  2636.  
  2637.     SEE ALSO
  2638.         SetPropertyList(), ReleaseMapping(), SetPropertiesA(),
  2639.         SetPropertiesMapping()
  2640.  
  2641. mmu.library/SetPropertiesMapping                mmu.library/SetPropertiesMapping
  2642.  
  2643.     NAME
  2644.         SetPropertiesMapping    -    transfer properties from a map list 
  2645.                                     to a context
  2646.  
  2647.     SYNOPSIS
  2648.         fine = SetPropertiesMapping ( ctx, list, base, length, mask );
  2649.         d0                              a0   a1     d0        d1        d2
  2650.  
  2651.         BOOL SetPropertiesMapping ( struct MMUContext *, struct MinList *,
  2652.                                  
  2653.                                  ULONG, ULONG, ULONG );
  2654.  
  2655.     FUNCTION
  2656.         Copy the properties of a memory map to a context, thru a mask.
  2657.         This is equivalent to SetPropertiesA(), except that the source
  2658.         data is contained in a memory map instead given as function
  2659.         arguments. This function is reverse to CopyContextRegion().
  2660.  
  2661.     INPUTS
  2662.         ctx        -    destination context whose memory map shall be set.
  2663.         list    -    the source memory map, containing the data to be 
  2664.                     transfered.
  2665.         base    -    base address of the memory region whose properties are
  2666.                     to be copied.
  2667.         length    -    length of the memory region in bytes whose properties
  2668.                     will be transfered.
  2669.         mask    -    a mask of property bits, see the SetPropertiesA() 
  2670.                     function for a detailed explanation. A zero bit in this
  2671.                     mask means that the corresponding property in the 
  2672.                     destination will be left alone and will remain unchanged.
  2673.  
  2674.     RESULTS
  2675.         a boolean success/failure indicator, TRUE for success. On failure,
  2676.         the destination context will not have been touched at all.
  2677.  
  2678.     NOTES
  2679.         This call does not copy memory at all, it just defines the memory
  2680.         properties of the context passed in.
  2681.  
  2682.         Check CopyMapping() to transport memory properties from one list
  2683.         to another, or CopyContextRegion() to transfer properties from a
  2684.         context to a list (the other direction).
  2685.  
  2686.         The library will not be able to perform checks for correct page 
  2687.         alignment, you have to do that yourself. 
  2688.     BUGS
  2689.  
  2690.     SEE ALSO
  2691.         SetPropertyList(), ReleaseMapping(), SetPropertiesA(),
  2692.         CopyContextRegion()
  2693.  
  2694. mmu.library/SetMappingPropertiesA            mmu.library/SetMappingPropertiesA
  2695.  
  2696.     NAME
  2697.         SetMappingPropertiesA    -    set memory attributes in a memory map.
  2698.  
  2699.     SYNOPSIS
  2700.  
  2701.         result = SetMappingPropertiesA( list, flags, mask, lower, size, tags);
  2702.         d0                                 a0        d1      d2    a1        d0      a2
  2703.  
  2704.         int SetMappingPropertiesA( struct MinList *, ULONG, ULONG, 
  2705.                                    ULONG, ULONG, struct TagItem *);
  2706.  
  2707.  
  2708.         result = SetMappingProperties( list, flags, mask, 
  2709.                                        lower, size, tag1, ...);
  2710.  
  2711.         int SetMappingProperties( struct MinList *, ULONG, ULONG, 
  2712.                                   ULONG, ULONG, Tag tag1, ...);
  2713.  
  2714.     FUNCTION
  2715.         This call sets attributes of a certain memory range of a given
  2716.         memory map.
  2717.  
  2718.     INPUTS
  2719.         list     - a minlist structure keeping the memory map to be altered.
  2720.         flags    - a binary flags field for the attributes to define. Check
  2721.                   SetProperties() for details about the defined bits.
  2722.         mask    - A bit mask of the attributes to be changed.
  2723.         lower    - The lower boundary of the logical address to be modified. 
  2724.         size    - Size of the region to be modified. 
  2725.         tags    - A tag array with additional data, identical to the
  2726.                   tags defined for SetPropertiesA().
  2727.  
  2728.     RESULTS
  2729.         Unlike SetPropertiesA() or SetPagePropertiesA(), this does not
  2730.         return a boolean value! The result code is 0 on failure, and
  2731.         different from zero on success, though. To be more precise, this
  2732.         routine will return "1" in case of success, and "2" in case the
  2733.         memory map was really altered and is now "dirty", hence upper
  2734.         software layers might require a "rebuild".
  2735.  
  2736.     NOTES
  2737.         This call really doesn't do anything to the MMU, it is just an
  2738.         administration call to modify a memory map - a handy data structure
  2739.         you might want to use for your own memory administration. Its
  2740.         context-based equivalent SetPropertiesA() will, hence, adjust the
  2741.         memory map which is kept by a context, and SetPagePropertiesA()
  2742.         will perform the same operation truely on the hardware.
  2743.  
  2744.         Since this call is not context based, the library will not be able
  2745.         to perform checks for correct page alignment, you have to do that
  2746.         yourself. Especially, note that SetPropertyList() - which attaches
  2747.         a memory map to a context - does not perform any check on this
  2748.         list either. Hence, *NOT* checking for page alignment here might
  2749.         result in an invalid context if you try to attach an incorrectly
  2750.         aligned list to a context later on. 
  2751.  
  2752.     BUGS
  2753.  
  2754.     SEE ALSO
  2755.         SetPropertyList(), ReleaseMapping(), SetPropertiesA(),
  2756.         SetPagePropertiesA(), GetMappingPropertiesA()
  2757.  
  2758. mmu.library/GetMappingPropertiesA            mmu.library/GetMappingPropertiesA
  2759.  
  2760.     NAME
  2761.         GetMappingPropertiesA     - read memory attributes from a memory map.
  2762.  
  2763.     SYNOPSIS
  2764.  
  2765.         flags = GetMappingPropertiesA( list, lower, tags);
  2766.         d0                                a0      a1     a2
  2767.  
  2768.         ULONG GetMappingPropertiesA( struct MinList *, ULONG, 
  2769.                                      struct TagItem *);
  2770.  
  2771.         result = GetMappingProperties( list, lower, tag1, ...);
  2772.  
  2773.         ULONG GetMappingProperties( struct MinList *, ULONG, Tag tag1, ...);
  2774.  
  2775.     FUNCTION
  2776.         This call reads the page properties of a certain address in
  2777.         memory from a memory map. It is the counterpart of 
  2778.         SetMappingPropertiesA() and the memory map analogue of 
  2779.         GetPropertiesA().
  2780.  
  2781.     INPUTS
  2782.         list    -    a MinList holding the memory map, obtained from either
  2783.                     GetMapping(), DupMapping() or NewMapping().
  2784.         lower    -     the logical address of the address to investigate. 
  2785.         tags    -   additional tags, identical to those defined for
  2786.                     GetPropertiesA(). Check the documentation of this
  2787.                     function for details.
  2788.  
  2789.     RESULTS
  2790.         Returns a binary flags field for the attributes to define. See
  2791.         SetPropertiesA() for details. 
  2792.  
  2793.     NOTES
  2794.         This call is the analogue of the GetPropertiesA() call. It operates
  2795.         directly on memory maps, unlike the former which operates only on
  2796.         the memory map of a context. This function does not require page 
  2797.         alignment because the mmu.library does not have a context to check
  2798.         the alignment restrictions, but you should note that a memory map
  2799.         that is to be attached to a context with DefineMapping() *HAS* to
  2800.         be correctly aligned.
  2801.  
  2802.         This routine is *NOT* safe to be called from within interrupts.
  2803.  
  2804.     BUGS
  2805.  
  2806.     SEE ALSO
  2807.         SetMappingPropertiesA(), SetPropertiesA(), GetPagePropertiesA(),
  2808.         GetPropertiesA()
  2809.  
  2810. mmu.library/SetPropertyList                        mmu.library/SetPropertyList
  2811.  
  2812.     NAME
  2813.         SetPropertyList        -    re-install a backup memory map
  2814.  
  2815.     SYNOPSIS
  2816.         SetPropertyList ( context, list );
  2817.                             a0        a1
  2818.  
  2819.         void SetPropertyList ( struct MMUContext * , struct MinList * );
  2820.  
  2821.     FUNCTION
  2822.         This call re-installes a property list, i.e. a complete memory
  2823.         map of a context, obtained from GetMapping() before.
  2824.     
  2825.     INPUTS
  2826.         context        -    the context the list should be installed in.
  2827.                         This should be the same context the list was
  2828.                         taken from.
  2829.         list        -    the property list to install. 
  2830.  
  2831.         This list *MUST* have been obtained with GetMapping() before.
  2832.  
  2833.     RESULTS
  2834.         Nothing. The big advantage of this call is that it cannot fail.
  2835.  
  2836.     NOTES
  2837.         The property list will become part of the context and is empty
  2838.         after this call. You can't re-use it for that reason. However,
  2839.         you still need to call ReleaseMapping() with the list pointer
  2840.         you've obtained before.
  2841.  
  2842.         For additional tips how this function should be used, see the
  2843.         GetMapping() function; especially, you can only un-do changes
  2844.         to the software abstraction level of a MMU-tree, and only as
  2845.         long as you haven't called RebuildTree() to translate these
  2846.         into hardware MMU tables. Trying to un-do these changes with
  2847.         SetPropertyList() will fail, and it will even fail if you call
  2848.         RebuildTree() afterwards. SetPropertyList() *does not* inform
  2849.         the software abstraction level about any changes, it is just a
  2850.         quick un-do operation. (For the experts: It even re-installs
  2851.         the "dirty" flags).
  2852.  
  2853.     BUGS
  2854.         
  2855.     SEE ALSO
  2856.         GetMapping(), ReleaseMapping(), RebuildTree()
  2857.  
  2858. mmu.library/GetMMUType                                    mmu.library/GetMMUType
  2859.  
  2860.     NAME
  2861.         GetMMUType - return the type of the MMU available in the system.
  2862.  
  2863.     SYNOPSIS
  2864.         mmu = GetMMUType( );
  2865.                         
  2866.  
  2867.         char GetMMUType( void );
  2868.  
  2869.     FUNCTION
  2870.         Returns an identifier for the MMU available in the system or
  2871.         NUL in case no MMU is installed.
  2872.  
  2873.     INPUTS
  2874.  
  2875.     RETURNS
  2876.         a character identifying the MMU type:
  2877.  
  2878.         MUTYPE_NONE                    no working MMU detected.
  2879.         MUTYPE_68851                a 68020 system with an external 68851
  2880.                                     MMU.
  2881.         MUTYPE_68030                a 68030 MMU.
  2882.         MUTYPE_68040                the internal 68040 MMU.
  2883.         MUTYPE_68060                the 68060 MMU.
  2884.  
  2885.     NOTES
  2886.         The mmu library is smart enough to detect EC processors without a
  2887.         working MMU, but the library does not detect multiple CPUs in the
  2888.         system. (How?)
  2889.  
  2890.     BUGS
  2891.  
  2892.     SEE ALSO
  2893.         mmu/mmubase.h
  2894. mmu.library/SuperContext                            mmu.library/SuperContext
  2895.  
  2896.     NAME
  2897.         SuperContext - find the supervisor context for a given context.
  2898.  
  2899.     SYNOPSIS
  2900.         super = SuperContext( context );
  2901.         d0                        a0                        
  2902.  
  2903.         struct MMUContext * SuperContext( struct MMUContext * );
  2904.  
  2905.     FUNCTION
  2906.         Returns the context that manages the supervisor mode for the user
  2907.         mode context passed in.
  2908.  
  2909.     INPUTS
  2910.         A user mode context or NULL for the current context.
  2911.  
  2912.     RETURNS
  2913.         A pointer to the context managing the supervisor type accesses with-
  2914.         in the current context.
  2915.  
  2916.     NOTES
  2917.         All contexts build by CreateMMUContext are by default user mode
  2918.         contexts. The current version of the library manages one global
  2919.         supervisor tree, and optionally private supervisor trees for private
  2920.         contexts if you ask for one on context creation. This is different 
  2921.         to former releases!
  2922.     
  2923.         To find the public supervisor mode context, call DefaultContext() 
  2924.         first and pass in its return value to this function.
  2925.  
  2926.     BUGS
  2927.  
  2928.     SEE ALSO
  2929.         DefaultContext(), CreateMMUContext()
  2930.  
  2931. mmu.library/DefaultContext                            mmu.library/DefaultContext
  2932.  
  2933.     NAME
  2934.         DefaultContext    -    get the global default context
  2935.  
  2936.     SYNOPSIS
  2937.         public = DefaultContext( );
  2938.         d0
  2939.  
  2940.         struct MMUContext * DefaultContext( void );
  2941.  
  2942.     FUNCTION
  2943.         Returns the global default user mode context which is used for
  2944.         tasks that are not attached to any other private context.
  2945.  
  2946.     INPUTS
  2947.  
  2948.     RETURNS
  2949.         A pointer to the context managing the user mode accesses for
  2950.         "context less" tasks.
  2951.  
  2952.     NOTES
  2953.         A task is by default part of this default context unless you
  2954.         call EnterMMUContext() and attach it to a different context.
  2955.  
  2956.         Note that you might have to enter even the default context
  2957.         explicitly to be able to use certain features of the exception
  2958.         hook mechanism.
  2959.  
  2960.     BUGS
  2961.  
  2962.     SEE ALSO
  2963.         SuperContext()
  2964. mmu.library/WithoutMMU                                mmu.library/WithoutMMU
  2965.  
  2966.     NAME
  2967.         WithoutMMU - execute a short subroutine with the MMU disabled.
  2968.  
  2969.     SYNOPSIS
  2970.         result = WithoutMMU( userFunc );
  2971.         d0                     a5
  2972.  
  2973.         ULONG WithoutMMU(void *);
  2974.  
  2975.     FUNCTION
  2976.         Executes a small assembly language routine pointed to in a5
  2977.         in supervisor mode, with all interrupts disabled, and the MMU
  2978.         disabled. All registers are preserved by this call.
  2979.         The function must end with an RTS instruction.
  2980.  
  2981.     INPUTS
  2982.         userFunc    -    A pointer to a *short* assembly language routine,
  2983.                         ending with RTS. The function has full access to
  2984.                         all registers.
  2985.  
  2986.     RETURNS
  2987.         whatever was left in register d0 by the called function.
  2988.  
  2989.     NOTES
  2990.         This is a low-level function. Remember that disabling the MMU
  2991.         might or might not be what you want, especially if memory is
  2992.         remapped.
  2993.  
  2994.     BUGS
  2995.         Big trouble if the supervisor stack is in remapped memory.
  2996.  
  2997.     SEE ALSO
  2998.         exec/Supervisor()
  2999. mmu.library/SetBusError                                mmu.library/SetBusError
  3000.  
  3001.     NAME
  3002.         SetBusError - define the bus error handler.
  3003.  
  3004.     SYNOPSIS
  3005.         SetBusError ( newfuncptr , oldfuncptrptr );
  3006.         d0                a0                a1
  3007.  
  3008.  
  3009.         void SetBusError ( void (*)() , void (**)() );
  3010.  
  3011.     FUNCTION
  3012.         This defines the bus error handler which is called in case the
  3013.         MMU library exception handler was not able to handle the fault.
  3014.  
  3015.         This happens for true physical bus errors, errors initiated by
  3016.         the unsupported TAS, CAS and CAS2 instructions using "locked
  3017.         transfers" not supported by the amiga hardware, and MOVE16 in-
  3018.         structions causing an access fault.
  3019.  
  3020.         The default bus error handler is whatever the library finds in
  3021.         the autovectors of the CPU when starting up. It is usually the
  3022.         exec fault handler which presents the nice guru 80000002.
  3023.  
  3024.     INPUTS
  3025.         newfuncptr    -    A pointer to the new bus error handler. It is
  3026.                         called without any parameters in supervisor state, 
  3027.                         with the exception stack frame on the stack.
  3028.         oldfuncptrptr -    A pointer to a pointer filled in with the previously
  3029.                         defined handler, or NULL.
  3030.  
  3031.     RETURNS
  3032.  
  3033.     NOTES
  3034.         The function pointer is guaranteed to be flushed to memory by
  3035.         the library, the function pointer pointer could be used, for
  3036.         example, to modify the destination of a JMP instruction.
  3037.  
  3038.         The bus error handler *MUST BE IMMEDIATELY* ready for run after
  3039.         this function has to be called.
  3040.  
  3041.         This is a low-level function. You do not want to call it.
  3042.  
  3043.     BUGS
  3044.  
  3045.     SEE ALSO
  3046.  
  3047. mmu.library/GetMMUContextData                    mmu.library/GetMMUContextData
  3048.  
  3049.     NAME
  3050.         GetMMUContextData - read MMUContext specific data
  3051.  
  3052.     SYNOPSIS
  3053.         GetMMUContextData ( ctx , id );
  3054.         d0                    a0    d0
  3055.  
  3056.         ULONG GetMMUContextData ( struct MMUContext * , ULONG );
  3057.  
  3058.     FUNCTION
  3059.         This function reads various parameters of the MMU context,
  3060.         indexed by an ID from mmu/mmutags.h. All legal tag items
  3061.         of CreateMMContext() are available, plus the following:
  3062.  
  3063.             MGXTAG_PAGESIZE        -        Return the page size in bytes
  3064.                                         of the input context. Unlike
  3065.                                         MCXTAG_PAGEBITS, this is *NOT*
  3066.                                         an exponent. This is identical
  3067.                                         to GetPageSize().
  3068.  
  3069.             MGXTAG_REMAPSIZE    -        Returns the alignment restriction
  3070.                                         for remapped memory to be added to
  3071.                                         the exec memory free list. This is
  3072.                                         identical to RemapSize().
  3073.  
  3074.             MGXTAG_ROOT            -        Return the pointer to the root of
  3075.                                         the MMU tree. You have to cast the
  3076.                                         result to an ULONG *. 
  3077.                                         Note that you DO NOT WANT to modify 
  3078.                                         this tree directly.
  3079.  
  3080.             MGXTAG_CONFIG        -        Returns the pointer to a 
  3081.                                         struct MMUConfig * specifying the
  3082.                                         complete MMU configuration for 
  3083.                                         this context. You usually DO NOT
  3084.                                         NEED to touch this.
  3085.  
  3086.     INPUTS
  3087.         ctx        -        A pointer to a struct MMUContext *.
  3088.  
  3089.         id        -        An ID specifying which data you want to read.
  3090.                         NOTE THAT THIS IS NOT A TAG LIST, but just the
  3091.                         tag item id from mmutags.h.
  3092.     RETURNS
  3093.         the data requested. You need to cast it to the correct type.
  3094.  
  3095.     NOTES
  3096.  
  3097.     BUGS
  3098.  
  3099.     SEE ALSO
  3100.         CreateMMUContext(), mmu/config.h
  3101.     
  3102. mmu.library/SetMMUContextDataA                mmu.library/SetMMUContextDataA
  3103.  
  3104.     NAME
  3105.         SetMMUContextDataA - define MMU context specifications on the fly
  3106.  
  3107.     SYNOPSIS
  3108.         SetMMUContextDataA ( ctx , tags );
  3109.                              a0    a1
  3110.  
  3111.         SetMMUContextData ( ctx , ... );
  3112.  
  3113.  
  3114.         void SetMMUContextDataA ( struct MMUContext * , struct TagItem * );
  3115.  
  3116.         void SetMMUContextData ( struct MMUContext * , Tag tag1 , ... );
  3117.  
  3118.     FUNCTION
  3119.         This function allows to adjust *some* of the MMUContext 
  3120.         specifications on the fly. The following tag items of the 
  3121.         CreateMMUContextA() call are supported:
  3122.  
  3123.             MCXTAG_BLANKFILL    -        define the data to read from the
  3124.                                         dummy "blank" pages. Note that
  3125.                                         a *working* program should never
  3126.                                         read this data.
  3127.  
  3128.             MCXTAG_MEMORYATTRS    -        define the memory attributes the
  3129.                                         MMU tables will be allocated from.
  3130.                                         This will *NOT* reallocate the MMU
  3131.                                         tables already build, cf. 
  3132.                                         exec/memory.h
  3133.  
  3134.             MCXTAG_EXECBASE        -        specify whether or not page 0 will
  3135.                                         be threated specially and accesses
  3136.                                         to the first Kbyte should be
  3137.                                         emulated. If set to FALSE, the 
  3138.                                         first page will be threated as all
  3139.                                         other pages.
  3140.  
  3141.             MCXTAG_ZEROBASE        -        Specify a base address for where 
  3142.                                         possibly emulated zero page accesses
  3143.                                         have to be redirected to. This address
  3144.                                         is usually ignored unless the zero-
  3145.                                         page is invalidated and MCXTAG_EXEBASE
  3146.                                         is TRUE. For the messy details, check
  3147.                                         the CreateMMUContext() autodocs.
  3148.  
  3149.         No other tag items are valid here.
  3150.  
  3151.     INPUTS
  3152.         ctx        -        A pointer to a struct MMUContext *.
  3153.  
  3154.         tags    -        A tag list containing the parameters to be
  3155.                         adjusted.
  3156.     RETURNS
  3157.  
  3158.     NOTES
  3159.  
  3160.     BUGS
  3161.  
  3162.     SEE ALSO
  3163.         CreateMMUContext(), exec/memory.h
  3164.  
  3165. mmu.library/BuildIndirect                            mmu.library/BuildIndirect
  3166.  
  3167.     NAME
  3168.         BuildIndirect        -    build a true hardware page descriptor.
  3169.  
  3170.     SYNOPSIS
  3171.         descr = BuildIndirect ( ctx , address , props );
  3172.         d0                        a0        d0          d1
  3173.  
  3174.         ULONG    BuildIndirect ( struct MMUContext * , ULONG , ULONG );
  3175.  
  3176.     FUNCTION
  3177.         This function builds a true hardware page descriptor, to be used for
  3178.         the MAPP_INDIRECT property. 
  3179.  
  3180.     INPUTS
  3181.         ctx        -    the MMUContext handle in which this descriptor is to
  3182.                     be used as the destination of a MAPP_INDIRECT descriptor.
  3183.  
  3184.         address    -    in case this descriptor is "valid", this is the 
  3185.                     PHYSICAL destination address, to be told to the MMU, to
  3186.                     which accesses will be redirected to. Unlike 
  3187.                     SetPropertiesA(), there is *NO* MAPP_REMAPPED bit. In
  3188.                     case you do not want remapping, set this to the logical
  3189.                     address. DO NOT LEAVE THIS BLANK or accesses will be
  3190.                     redirected to address 0 - which is most likely not want
  3191.                     you want. Note that this address must be, as all other
  3192.                     addresses the MMU cares about, page aligned!
  3193.                     In case this descriptor is of invalid type, the address
  3194.                     can be used for your purposes, but note that this MUST
  3195.                     STILL be a number which is page aligned for the given
  3196.                     context. It *MAY NOT* be arbitrary.
  3197.                 
  3198.         props    -    Properties for the descriptor to be defined.
  3199.                     NOTE THAT THIS IS A TRUE HARDWARE DESCRIPTOR! The
  3200.                     library WILL NOT BE ABLE to help you out by emulating
  3201.                     missing features of one MMU or another. Instead, it will
  3202.                     just ignore them. This means for you, specifically, 
  3203.                     that only a minor subset of the usual properties may be
  3204.                     used safely here, and that parsing the hardware 
  3205.                     properties later on with GetIndirect() might result in
  3206.                     different properties than you intended because of
  3207.                     missing features of the MMU in use. To be precise, the
  3208.                     following properties *might* be available - meaning that
  3209.                     all others ARE NOT!
  3210.  
  3211.                 MAPP_WRITEPROTECTED     -    The page will be write protected. 
  3212.                     Writes to this area will cause a segmentation fault.
  3213.  
  3214.                 MAPP_USED                -    The "used" bit of the pages
  3215.                     will be set. The CPU will set this bit automatically
  3216.                     as soon as the pages are accessed.
  3217.  
  3218.                 MAPP_MODIFIED            -    The "modified" bit of the pages
  3219.                     will be set. The CPU will set this bit automatically
  3220.                     as soon as a write is performed to the page in question.
  3221.                     DO NOT SET THIS BIT TOGETHER WITH MAPP_WRITEPROTECTED
  3222.                     OR WITHOUT MAPP_USED or the CPU might hang. 
  3223.  
  3224.                 MAPP_INVALID            -    The page will be marked as 
  3225.                     invalid. Accessing it will invoke the bus error hook.
  3226.                     See below for how to mark this page as REMAIRABLE. Note
  3227.                     that the MAPP_REPAIRABLE bit is *here* not available.
  3228.  
  3229.                 MAPP_SWAPPED            -    The page will be marked as
  3230.                     swapped out. This is for this kind of descriptors 
  3231.                     identical to MAPP_INVALID and will be read as such
  3232.                     later on.
  3233.  
  3234.                 MAPP_CACHEINHIBIT        -    The page will be marked as non-
  3235.                     cacheable.
  3236.  
  3237.                 MAPP_IMPRECISEEXECPTION    -    The page will be marked as 
  3238.                     "imprecise exception". MAPP_CACHEINHIBIT is mandatory
  3239.                     in this case or this flag does nothing. Only avail-
  3240.                     able for the 060, ignored and read as zero 
  3241.                     by all others.
  3242.  
  3243.                 MAPP_NONSERIALIZED        -    The page will be marked as
  3244.                     serialized. MAPP_CACHEINHIBIT is mandatory if this
  3245.                     property is selected. Only available for the 040, 
  3246.                     ignored and read as zero by all others.
  3247.  
  3248.                 MAPP_COPYBACK            -    The page will be marked as
  3249.                     "copyback" instead of "writethrough". Generally re-
  3250.                      commended since this is faster for the '40 and '60.
  3251.                     MAPP_CACHEINHIBIT *MUST* be disabled for this to work.
  3252.                     Only available for the 040 and 060, ignored and read
  3253.                     as zero by others.
  3254.  
  3255.                 MAPP_USERPAGE0            -    Set user page attribute 0,
  3256.                     only available for the 040 and 060, ignored and read
  3257.                     as zero by all others.
  3258.                     The status of this bit appears on special pins of the
  3259.                     CPU and might be required by some hardware, so don't     
  3260.                     play with this. 
  3261.  
  3262.                 MAPP_USERPAGE1            -    Set user page attribute 1,
  3263.                     see above for details.
  3264.  
  3265.                 MAPP_GLOBAL                -    DIFFERENT TO SetProperties()
  3266.                     and others! 
  3267.                     Set the GLOBAL bit in the page descriptor, only avail-
  3268.                     able for the 040 and 060, ignored and read as zero by
  3269.                     all others. 
  3270.                     Setting this bit means that certain specialized 
  3271.                     instructions will not flush this descriptor from the
  3272.                     cache (the ATC) of the MMU.
  3273.                     The mmu.library writes only descriptors without this
  3274.                     bit set and does not use these instructions. It will
  3275.                     always flush descriptors independent of the G bit.
  3276.                     There is little use of this bit.
  3277.  
  3278.     RESULTS
  3279.         a page descriptor for the current MMU in use, designed and to be
  3280.         used for as the destination of an MAPP_INDIRECT descriptor. NOT
  3281.         to be used as a true page descriptor, and NOT to be used as a 
  3282.         table descriptor.
  3283.         In case the library finds no MMU or the alignment restrictions 
  3284.         aren't satisfied, it will return BAD_DESCRIPTOR (0x03), it 
  3285.         WILL NOT return NULL as this is a "valid invalid" descriptor.
  3286.             
  3287.     NOTES
  3288.         Note specifically that MAPP_SUPERVISORONLY *IS NOT* supported. The
  3289.         mmu.library enforces a distinct user/supervisor model and as such
  3290.         you might want to install an invalid descriptor into the user table
  3291.         and a valid descriptor into the supervisor table to emulate this
  3292.         feature. True "supervisor only" descriptors are available for the
  3293.         040 and 060 anyways, but this "emulation" works for all MMUs.
  3294.  
  3295.         MAPP_REMAPPED is not supported either because you have to specify
  3296.         a physical destination address in all cases, even if no remapping
  3297.         has to be performed. Use the logical address as physical address in
  3298.         case remapping is not desired.
  3299.  
  3300.         MAPP_REPAIRABLE is not available because this flag is in fact an
  3301.         emulation provided by the library. However, you may make access 
  3302.         faults to this page repairable by setting the MAPP_REPAIRABLE bit
  3303.         for the MAPP_INDIRECT descriptor that POINTS to the descriptor 
  3304.         you're building by this call. This will be enough to inform the
  3305.         library about how to treat access faults.
  3306.         
  3307.  
  3308.         How to use this function:
  3309.  
  3310.         Allocate four bytes of memory, long-word aligned, and gets its
  3311.         TRUE PHYSICAL location with PhysicalLocation(), build a descriptor 
  3312.         with this call and install it into this memory by calling 
  3313.         SetIndirect(). *DO NOT* write it to the memory yourself! 
  3314.         Due to CPU caching effects, this must be done by the library. 
  3315.         Then build a MAPP_INDIRECT descriptor, and tell the library with the
  3316.         MAPTAG_DESCRIPTOR tag of SetPropertiesA() to make it point to your
  3317.         memory. In case you want access faults on this to be repairable,
  3318.         set the MAPP_REPAIRABLE bit for this call. In case you want it write 
  3319.         protected but want to ignore write accesses, set MAPP_ROM, too. Then
  3320.         call RebuildTree() as usual. In case you want to exchange descriptors
  3321.         really fast - this is after all what indirect descriptors are 
  3322.         designed for - build all descriptors you require in a first step
  3323.         and keep them. A single call to SetIndirect() will exchange them
  3324.         VERY RAPIDLY which is ideal for certain applications. 
  3325.     
  3326.     BUGS
  3327.         Much more must be said about this function. It is definitely an
  3328.         advanced feature, so don't play with this in case you don't know
  3329.         what it does.
  3330.  
  3331.     SEE ALSO
  3332.         SetIndirect(), GetIndirect()
  3333.  
  3334. mmu.library/SetIndirect                                mmu.library/SetIndirect
  3335.  
  3336.     NAME
  3337.         SetIndirect        -    Write a page descritor to memory
  3338.  
  3339.     SYNOPSIS
  3340.         SetIndirect ( destination , logical , descriptor );
  3341.                         a0            a1            d0
  3342.  
  3343.         void SetIndirect ( ULONG *, ULONG, ULONG );
  3344.  
  3345.     FUNCTION
  3346.         Write a page descriptor, used as the destination of one or
  3347.         several MAPP_INDIRECT descriptors, out to memory and make the MMU
  3348.         aware of the change.
  3349.  
  3350.     INPUTS
  3351.         destination        -    the memory location to which the descriptor
  3352.                             should be written to. This is the same address
  3353.                             specified by MAPTAD_DESCRIPTOR in the corresponding
  3354.                             SetProperties() call. NOTE THAT THIS IS A 
  3355.                             PHYSICAL, NOT A LOGICAL ADDRESS.
  3356.  
  3357.         logical            -    The logical address covered by this descriptor, 
  3358.                             i.e. the address of the page which this 
  3359.                             descriptor is managing. In case you installed
  3360.                             the same descriptor for several logical addresses,
  3361.                             specify -1L.
  3362.  
  3363.         descriptor        -    The descriptor to install.
  3364.  
  3365.     RESULTS
  3366.         doesn't return a result.
  3367.  
  3368.     NOTES
  3369.         Do NOT try to install a descriptor yourself, even though this 
  3370.         *seems* to be more effective. Somewhat more must be done than just
  3371.         writing the descriptor to memory. This call ensures that the
  3372.         descriptor is really written out to memory, and really fetched by
  3373.         the MMU. Specifying -1 as logical address is possible and supported
  3374.         but *slightly* less efficient than giving the correct 
  3375.         logical address.
  3376.         This call DOES NOT ensure that all data in the page to be modified
  3377.         is really written out. Hence, if you change the cache mode, the
  3378.         protection status or the validity status of a page, you should call
  3379.         CacheClearU() or CacheClearE() before. Furthermore, note that the
  3380.         cache of the 020 and 030 keeps logical addresses. On these processors,
  3381.         you must flush the cache, too, if you install a descriptor which    
  3382.         points to a different physical address.
  3383.  
  3384.         This call is *very* effective, there is little reason to try this
  3385.         yourself, not counting the portability problems.
  3386.  
  3387.     BUGS
  3388.  
  3389.     SEE ALSO
  3390.         GetIndirect(), BuildIndirect()
  3391.  
  3392. mmu.library/GetIndirect                                mmu.library/GetIndirect
  3393.  
  3394.     NAME
  3395.         GetIndirect        -    Read a hardware page descritor from memory
  3396.  
  3397.     SYNOPSIS
  3398.         GetIndirect ( ctx , adt , address );
  3399.                       a0    a1        d0
  3400.  
  3401.         void GetIndirect ( struct MMUContext *, 
  3402.                            struct AbstractDescriptor *, ULONG * );
  3403.  
  3404.     FUNCTION
  3405.         Reads a true hardware page descriptor, used as the destination 
  3406.         of one or several MAPP_INDIRECT descriptors, and places its data
  3407.         in the AbstractDescriptor structure.
  3408.  
  3409.     INPUTS
  3410.         ctx                -    the MMU context handle this page descriptor
  3411.                             belongs.
  3412.         adt                -    An abstract table descriptor, to be filled
  3413.                             out with the descriptor data.
  3414.         address            -    the address from where the descriptor is to 
  3415.                             be read. This is the same address which has been
  3416.                             passed as argument to the MAPTAG_DESCRIPTOR
  3417.                             tag of the SetPropertiesA() call when building
  3418.                             the indirect descriptor.
  3419.     
  3420.     RESULTS
  3421.         no direct result code, but the AbstractDescriptor is filled
  3422.         out:
  3423.  
  3424.         struct AbstractDescriptor {
  3425.             ULONG        atd_Pointer;
  3426.             ULONG        atd_Properties;
  3427.             UWORD        atd_LowerLimit;
  3428.             UWORD        atd_UpperLimit;
  3429.             UBYTE        atd_ThisType;
  3430.             UBYTE        atd_NextType;
  3431.             UWORD        atd_reserved;
  3432.         };
  3433.  
  3434.         atd_Pointer is either the physical address the accesses to the
  3435.         page(s) this descriptor is installed for are redirected to, or
  3436.         the user data if this descriptor is of invalid type. This is the
  3437.         same value that was passed in as "address" argument to the
  3438.         corresponding BuildProperties() call.
  3439.  
  3440.         atd_Properties is the set of MMU properties read from the 
  3441.         descriptor. This NEED NOT to be identical to the properties setup
  3442.         by BuildIndirect(), for two reasons: First, the MMU sets the
  3443.         USED and MODIFIED attributes as soon as any access or a write
  3444.         access happens to the page(s) handled by the descriptor. Second,
  3445.         not all MMUs support all properties. Unavailable properties are
  3446.         ignored by BuildIndirect(), and read as zero by this function.
  3447.  
  3448.         All other fields are currently not documented and should not be
  3449.         read.
  3450.  
  3451.     NOTES
  3452.         Do NOT try to read a descriptor yourself, even though this 
  3453.         *seems* to be more effective. Somewhat more care must be kept for
  3454.         doing this. NOT following this rule might even lock up your
  3455.         machine!
  3456.  
  3457.         This call is *very* effective, there is little reason to try this
  3458.         yourself, not counting the portability problems.
  3459.  
  3460.     BUGS
  3461.  
  3462.     SEE ALSO
  3463.         SetIndirect(), BuildIndirect(), mmu/descriptor.h
  3464.